I have this example of server sent events from w3schools. The .php code works fine. However, I need the .asp version and that example doesn't work. I not getting any response from the server side script. Any help?
<!-----------Client side-------------->
<!DOCTYPE html>
<html>
<body>
<h1>Getting server updates</h1>
<div id="result"></div>
<script>
if(typeof(EventSource) !== "undefined") {
var source = new EventSource("demo_sse.asp");
source.onmessage = function(event) {
document.getElementById("result").innerHTML += event.data + "<br>";
};
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support server-sent events...";
}
</script>
</body>
</html>
<!---------------Server side--------------->
<%
Response.ContentType = "text/event-stream"
Response.Expires = -1
Response.Write("data: The server time is: " & now())
Response.Flush()
%>
You might not believe this but... try this line:
Response.Write("data: The server time is: " & now()) & vbCrLf & vbCrLf
This works for me! See this answer - the last one