Skip to content

Commit

Permalink
output sse closed
Browse files Browse the repository at this point in the history
  • Loading branch information
Adminbck committed Jun 23, 2024
1 parent 2f71853 commit b3df784
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,15 @@ <h1>Server-Sent Events</h1>

<script>
const eventSource = new EventSource('https://melendriu.homepc.it:8888/events');
eventSource.onmessage = function(event) {
const dataElement = document.getElementById('sse-data');
const dataElement = document.getElementById('sse-data');

eventSource.onmessage = function(event) {
dataElement.innerHTML = event.data + '<br>';
};

eventSource.onerror = function(event) {
eventSource.close();
dataElement.innerHTML = 'Finished..<br>';
};
</script>

Expand Down

0 comments on commit b3df784

Please sign in to comment.