开发者

Does PHP flush work with jQuerys ajax?

开发者 https://www.devze.com 2023-01-08 07:33 出处:网络
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 jQu

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);
        }
})


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."


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消