Does PHP flush work with jQuerys ajax?

旧街凉风 提交于 2019-11-30 09:33:04

问题


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

回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/3276542/does-php-flush-work-with-jquerys-ajax

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!