Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is not a server side issue, this all happens on the client and is part of the spec (I know it sounds weird).</p> <p><a href="http://dev.w3.org/html5/eventsource/" rel="nofollow">http://dev.w3.org/html5/eventsource/</a></p> <p>"When a user agent is to reestablish the connection, the user agent must run the following steps. These steps are run asynchronously, not as part of a task. (The tasks that it queues, of course, are run like normal tasks and not asynchronously.)"</p> <ol> <li> Queue a task to run the following steps: <ol> <li>If the readyState attribute is set to CLOSED, abort the task.</li> <li>Set the readyState attribute to CONNECTING.</li> <li>Fire a simple event named error at the EventSource object.</li> </ol> </li> </ol> <p>I can't see any need to have an error here, so I have modified your Init function to filter out the error event fired whilst connecting.</p> <pre><code>function init() { var CONNECTING = 0; var source; if (!!window.EventSource) { source = new EventSource('events.php'); source.addEventListener('message', function (e) { document.getElementById('output').innerHTML += e.data + '<br />'; }, false); source.addEventListener('open', function (e) { document.getElementById('output').innerHTML += 'connection opened<br />'; }, false); source.addEventListener('error', function (e) { if (source.readyState != CONNECTING) { document.getElementById('output').innerHTML += 'error<br />'; } }, false); } else { alert("Browser doesn't support Server-Sent Events"); } }</code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload