I'm using some client-side JavaScript code to pull a lot of JSON data from a webserver via an HTTP GET. The amount of data can be big, say 50 MB. This is on a LAN so it's not much of a problem, but it still takes ten seconds or so.
To make my interface more responsive, I would like to process the response in chunks, showing data in the UI as soon as it becomes available (let's say, per MB or per second). Browser compatibility is not an issue; as long as it works on the latest Chrome and Firefox it'll be okay. However, I cannot modify the server code.
Is it possible to do this, using XMLHttpRequest or WebSockets or some other technology I haven't heard of?
XMLHttpRequest.responseText
is not explicitly empty while the state is LOADING
:
The responseText attribute must return the result of running these steps:
- If the state is not LOADING or DONE return the empty string and terminate these steps.
- Return the text response entity body.
But I suppose buffering will happen at various stages along the way, so will it work if I set a timer to periodically poll responseText
?
As far as I can tell, WebSockets require a special protocol on the server side as well, so those are out.
Restriction: I cannot modify the server code.