Horje
How to Receive Server-Sent Event Notifications | HTML SSE API Code
How to Receive Server-Sent Event Notifications

The EventSource object is used to receive server-sent event notifications:


Example of Receiving Server-Sent Event Notifications

The EventSource object is used to receive server-sent event notifications:
index.html
Example: HTML
<h1>Getting server updates</h1>
<div id="result"></div>

<script>
if(typeof(EventSource) !== "undefined") {
  var source = new EventSource("demo_sse.php");
  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>

Output should be:

Example of Receiving Server-Sent Event Notifications

Example explained: Receive Server-Sent Event Notifications

Reffered: https://www.w3schools.com/html/html5_serversentevents.asp



Read Full::
HTML SSE API Code
Category:
HTML Code
Sub Category:
HTML SSE API Code
Uploaded:
1 month ago
Uploaded by:
Admin
Views:
9

Related Articles
What is HTML SSE API HTML SSE API Code
How to add Server-Sent Events - One Way Messaging HTML SSE API Code
What types of browsers will support HTML SSE API HTML SSE API Code
How to Receive Server-Sent Event Notifications HTML SSE API Code
How to Check Server-Sent Events Support HTML SSE API Code
What is Server-Side Code Example HTML SSE API Code
What are The EventSource Object HTML SSE API Code

Single Articles
Example of Receiving Server-Sent Event Notifications
Example explained: Receive Server-Sent Event Notifications

Share on: