I got this code from W3Schools.com, its an example of server-sent event:
<!DOCTYPE html>
<html>
<body>
<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+="<br>" + event.data;
};
}
else
{
document.getElementById("result").innerHTML="Sorry, your browser does not support server-sent events...";
}
</script>
</body>
</html>
My question is how to edit the code so that new entry comes above the old entry?
I am unable to figure out how to do it. Can someone help me?
Well
takes the document and APPENDS the new data to it.
Im surprised you havent tried