MrAwesome
MrAwesome

Reputation: 163

Does PHP flush work with jQuerys ajax?

I have created a page in which I use the PHP function flush(), to output data to the browser the second the data is echoed. I'm also calling this page using jQuery's ajax function. It works, but jQuery doesn't output anything until the entire page has executed, which kind of removes the functionality of flush().

How can I fix this?

My ajax call looks like this:

jQuery.ajax({
        type: "get",
        url: url,
        data: postdata,
        success: function(retval) {
             jQuery('#retdiv").html(retval);
        }
})

Upvotes: 2

Views: 3924

Answers (2)

Sebastián Grignoli
Sebastián Grignoli

Reputation: 33462

Here you have 2 plugins for streaming:

JQUERY AJAX HTTP STREAM and JSTREAMPLUG.

http://plugins.jquery.com/taxonomy/term/1840

"This plugin allows for a constant connection with a server keeping content continuously updated with the latest content using one http request. It extends the $.ajax, $.get, and $.post functions to allow for streaming."

Upvotes: 5

Jhong
Jhong

Reputation: 2752

jQuery needs to wait for the connection to close before it can insert the html onto the page -- it can't display it progressively (it wouldn't make any sense).

Upvotes: 0

Related Questions