2

javascript/jquery question:

I want the browser to read a stream of numeric data (comma-separated integers) from a http-url on the server.

The stream is finite, but can be quite long, and I would like to start processing the data in javascript (draw a html5/canvas/2d graph) incrementally as the data is received, without waiting for end-of-stream before start drawing.

But how do I read the http-stream incrementally? I figured this would be a quite common use-case, but still cannot easily google up a good example...

Can I do this with $.ajax() function?

If so, what event should I respond to, and how do I read data from the partial, incomplete stream that has arrived so far?

Rop
  • 3,359
  • 3
  • 38
  • 59
  • Maybe duplicate of http://stackoverflow.com/questions/7740646/jquery-ajax-read-the-stream-incrementally – Stephan Kulla Apr 14 '14 at 23:09
  • @tampis I've seen that question, but where exactly is the working answer? It's a link to the "Ajax Patterns" site with snippets of php-code (server-side). What's that got to do with javascript (client-side)? I dont get it... – Rop Apr 15 '14 at 04:22

1 Answers1

2

For the records... I got answers on the jQuery Forum:

http://forum.jquery.com/topic/process-http-data-stream-incrementally-from-browser

In short:

  • No efficient javascript solution for http stream.

  • Instead, use webSockets, or split the data-stream into multiple shorter chunks.

Rop
  • 3,359
  • 3
  • 38
  • 59