EventSource push of H5
EventSource push (ajax normal polling)
Subscribe to if (window.EventSource) {var eventSource = new EventSource (""); eventSource.onmessage = function (e) {document.body [XSS _ clean] + = e.data +'
';}; / / whenever you connect to the server, the open event eventSource.addEventListener ("open", function () {console.log ("establishing a connection with the server"); / / processes the load event eventSource.addEventListener in the server response message ("load", function (e) {console.log ("data sent by the server to the client is" + e.data);}) / / if no event is specified in the server response message, the message event eventSource.addEventListener ("message", function (e) {console.log ("data sent by the server to the client is" + e.data);}) is triggered by default; / / if an error occurs, the error event eventSource.addEventListener ("error", function (e) {console.log ("data sent by the server to the client is" + e.data);}) is triggered) } else {console.log ("the server does not support EvenSource objects");} eventSource.addEventListener ("open", function () {console.log ("establish a connection with the server");}) / / process the load event eventSource.addEventListener in the server response message ("load", function (e) {console.log ("server load data is:" + e.data);}) / / if no event is specified in the server response message, the message event eventSource.addEventListener is triggered by default ("message", function (e) {console.log ("the data sent by the server to the client is:" + e.data);}) / / if an error occurs, the error event eventSource.addEventListener ("error", function (e) {console.log ("server error data is" + e.data);});} else {console.log ("the server does not support EvenSource objects");} / / var count = 0 / / var comet = new iComet ({/ / channel: 'ch2', / / subUrl:', / / callback: function (content, type) {/ / count + +; / / var output = document.getElementById ('output'); / / var time =''+ (new Date ()) / / output [XSS _ clean] + = count +'. '+ time +': ('+ type +')'+ content +'; / /} /})