2
我在系统中使用长轮询作为推送机制。 它在Chrome浏览器工作正常,但在IE8中行为很奇怪: 它加载5次正常(即,我能够刷新(F5)该页面5次,html被加载并且所有脚本都在运行正确)之后,IE8拒绝执行和网络连接(我检查了Fiddler2)并简单地显示“加载”图标无限。 现阶段唯一的治疗方法是关闭并打开浏览器本身。
我正在使用JQuery和PHP。IE8在5次长轮询请求后停止网络访问
这里是我的初始化代码:
setTimeout(function() // called from $(function(){}), jquery page ready event
{
start_polling();
},1000);
function start_polling()
{
$.ajax(
{
url: "/push",
// must avoid cache because sometimes user is logged in and sometimes not
data:
{
"anticache":Math.random()
},
type: "post",
timeout: 30000, // half a minute before each restart long polling
success: function(data)
{
var dataObj = eval("("+data+")");
{
create_notif("withIcon",
{
title: dataObj.title,
text: dataObj.text,
icon: "/img/"+dataObj.type+".png"
},
{
click: function(e, instance)
{
instance.close();
}
});
}
start_polling();
},// end success of ajax load
error: function(x,t,m)
{
if(t==="timeout") {
//alert("got timeout");
start_polling();
} else {
//alert(t);
}
//start_polling();
}
}) // end ajax
} // start polling
更新:它已经改善,但远非完美。也许应该有某种插件收集所有的“ajax”请求并自动对其应用“中止”? –