Of course your own pages may execute functions on user interaction, but for the purposes of this demonstration add the following script at the end of your page, before the closing body tag: The script first checks that the browser supports the Event Source model.If it doesn’t, an error message is written to the server data page element instead.
In this tutorial we have carried out the basics of using Server-Sent events with HTML5, Java Script and PHP.
We will use HTML5 and Java Script at client side, with PHP at server side.
With existing models such as AJAX, the code in a Web page would continually ask the server to supply new data, but the onus was on the client to request the information.
The HTML5 Server-Sent event model allows you to push realtime data updates from the server to the browser.
In this tutorial we will work through the process, with the Event Source object handling received data and writing it to the page.The placeholder text should only appear when the page first loads, but will disappear when the script runs.