Horje
What is Server-Side Code Example | HTML SSE API Code
What is Server-Side Code Example

For the example above to work, you need a server capable of sending data updates (like PHP or ASP).

The server-side event stream syntax is simple. Set the "Content-Type" header to "text/event-stream". Now you can start sending event streams.


Example of Server-Side Code Example Code in PHP

Code in PHP

demo_sse.php
Example: PHP
 <?php
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');

$time = date('r');
echo "data: The server time is: {$time}\n\n";
flush();
?>

Example of Server-Side Code Example Code in PHP Code in ASP

Code in ASP

demo_sse.asp
Example: ASP
<%
Response.ContentType = "text/event-stream"
Response.Expires = -1
Response.Write("data: The server time is: " & now())
Response.Flush()
%> 

Code explained: Server-Side Code Example

 

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:
2

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 Server-Side Code Example Code in PHP
Example of Server-Side Code Example Code in PHP Code in ASP
Code explained: Server-Side Code Example

Share on: