切换布局
显示结果
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>迹忆客(jiyik.com)</title> <base href="//tools.jiyik.com/demo_source/" target="_blank" > </head> <body> <h1>获取服务端更新数据</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="抱歉,你的浏览器不支持 server-sent 事件..."; } </script> </body> </html>