What is SSEs? Server-sent events (SSE) is a technology for where a browser gets automatic updates from a server via HTTP connection. The Server-Sent Events EventSource API is standardized as part of HTML5[1] by the W3C. SSEs vs WebSockets SSEs can only push data to the browser. Websockets can both send data to the browsr and receive data from the browser. SSEs is easier to implement. SSEs are send over traditional HTTP.That means they don't require a special protocol to get working. Websockets require full-duplex connections and new Web Socket serves to handle the protocol. Who does not support it ? IE & Andriod browser 4.3- doesn't support Server-sen DOM events ➽See more here How to get working ? JAVASCRIPT $(function() { if (!window.EventSource) { //XHR return; } source.addEventListener('message', function(e) { console.log(e.data); $rs = $.parseJSON(e.data); }, false); source.addEventListener(...
一個網頁設計師經驗分享部落格,內容涵蓋HTML, CSS, RWD, Nodejs, React 的技術。