The EventSource object is used to receive server-sent event notifications: |
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>
Reffered: https://www.w3schools.com/html/html5_serversentevents.asp
What is HTML SSE API | HTML SSE API |
How to add Server-Sent Events - One Way Messaging | HTML SSE API |
What types of browsers will support HTML SSE API | HTML SSE API |
How to Receive Server-Sent Event Notifications | HTML SSE API |
How to Check Server-Sent Events Support | HTML SSE API |
What is Server-Side Code Example | HTML SSE API |
What are The EventSource Object | HTML SSE API |
Example of Receiving Server-Sent Event Notifications | HTML SSE API |
Example explained: Receive Server-Sent Event Notifications | HTML SSE API |
Read Full: | HTML SSE API |
Category: | Web Tutorial |
Sub Category: | HTML SSE API |
Uploaded: | 1 year ago |
Uploaded by: | Admin |
Views: | 32 |