View Single Post
Old 05-25-2020, 08:42 AM   #11
sherman
Guru
sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.
 
Posts: 876
Karma: 2676800
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
Quote:
Originally Posted by jefferson View Post
I am currently testing sse, but it doesn't seem to work. It might be some bug on my site, but it works on my desktop browser. Do you maybe still have some code samples which have worked for you?
Make sure you aren't using any modern javascript features. ECMAScript 2015 (ES6) is definitely a no go.

I've used the event field myself. Something like the following worked for me:
Code:
var evtSource = new EventSource("/messages");
evtSource.addEventListener("body", function (event) {
    // code goes here
});
Note, using let for declaring variables is a no-go. Possibly const as well. To be safe, I'd stick with var.
sherman is offline   Reply With Quote