Hello,

I have a HTTP server that answers a CGI request with a never endind
ascii stream of data.

I would like to make a async ajax call to that CGI and process the
data as it arrives without having to wait endlessly for the end of the
reply.

So far I have got this:

$(function(){
        var a = $.ajax({
    url: "data.cgi",
        success: function(data){
                        alert( "Data stream never ends, This is an error");
                }
    });
    a.onreadystatechange = function() {
      if (a.readyState == 3 /*state == LOADING*/) {
        var len = a.responseText.length;
                //do something usefull with a.responseText[0] to a.responseText
[len]...
};

It works for some time, but a.responseText grows indefinitely so
eventually it will come out of memory.

I can modify a bit how the server sends the data, for example I tried
to serve the data in a multipart. I was hoping that the "success"
function would be called after each part of the multipart and
a.responseText would be reset after that, but this is not the case,
the "success" function never get's called (even with a.multipart =
true)

The server is running on a 8bit 60Mhz microcontroler, so I cannot poll
for data every X seconds. Is there a way jQuery can support "long
polling" without having the XMLHttpRequest.responseText buffer grow
indefinitely?

Thanks in advance for your help

Reply via email to