Basic Server Sent Events

Example creating a basic SSE connection.

Preview

Code

<p id="demo"></p>

<script>
if(typeof(EventSource)!=="undefined"){
 var source=new EventSource("sse.php");

 source.onmessage=function(event){
  document.getElementById("demo").innerText=event.data;
 };
}
</script>

More HTML SSE Examples (3)