If I do have the velow html5 element:
<div>
Counter: <span id="content"></span>
</div>
And my server is returning a counter, I can listen to this counter, and display it at the above element as:
var source = new EventSource("http://localhost:8080/counter");
source.onmessage = function (event) {
var data = JSON.parse(event.data);
document.getElementById("content").innerHTML = counter;
}
But what if the server is sending me a multipart/x-mixed-replace, how can I receive it in the JavaScript code, and display its content in a div or 'objector evenimage`, the server is expected to send me multiple images that can be displayed as video streaming.
I saw this but could not understand how to do it in JavaScript at browser.
Pure JavaScript please.
Note: I was able to do it as:
<object data="http://localhost:8080/camera" width="300" height="200" alt="Cam streaming"></object>
But I prefer using SSE (Server-Sent-Event) to do it.