我正在尝试用下面的代码实现某种"comet“:
<?php
header("Content-type: text/html;charset=utf-8;");
print ob_get_level ();
ob_end_flush(); //ends the automatic ob started by PHP
for ($i = 0; $i < 10; $i++) {
$randSlp=rand(1,3);
echo "Sleeping for ".$randSlp." second. ";
flush();
sleep(1);
var_dump( ob_get_level());
}
?>但在完成之前,它不会发送200 OK。
我想在加载的时候获取它,并使用Jquery做一些事情,所以我认为readyState应该是3。
但是如果JQuery jqxhr对象没有实现onReadyStateChange,我该怎么做呢
非常感谢。
发布于 2014-12-09 06:25:00
实际上,在Jquery中没有提供onreadystatechange机制,然而,由于done、fail、always和statusCode涵盖了所有可能的需求。
由文档http://api.jquery.com/jquery.ajax/提供
因此您应该使用XMLHttpRequest,请参阅http://www.w3schools.com/ajax/ajax_xmlhttprequest_onreadystatechange.asp
https://stackoverflow.com/questions/18765817
复制相似问题