HTML5 - Introduction
HTML5 - New Elements
HTML5 - Removed Elements
HTML5 - Browser Check
Tag Name : server-sent-events
The 'Server Sent Events' a.k.a SSEs crosses into the scripting world. SSEs enable a web page receive messages 'automatically' from a server based backend script. This backend script could be a PHP, ColdFusion, .net, Java or any web technology based script.
The emphasis is to be placed on the word 'automatically'. The web page does not need to have any explicit code to issue calls to the back end server based script and ask for updates (messages).
HTML Example :

<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
Server sent time : <div id=msg></div>

<script>
var server_resource=new EventSource("t_sse_resource.php");
server_resource.onmessage=function(event)
{
document.getElementById("msg").innerHTML=event.data;
};
</script>

</body>
</html>
Server Side Script code [t_sse_resource.php) :

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

$time = date('h:i:s');
echo "data: {$time}\n\n";
flush();
?>

© 2010 www.generalconnection.com. All rights reserved. | www.generalconnection.com