gpt4 book ai didi

internet-explorer - IE8在5次长轮询请求后停止网络访问

转载 作者:行者123 更新时间:2023-12-01 05:04:23 25 4
gpt4 key购买 nike

我在我的系统中使用长轮询作为推送机制。它在 Firefox 和 Chrome 中工作正常,但在 IE8 中行为很奇怪:它加载正常 5 次(即我能够刷新(F5)页面 5 次,html 已加载并且所有脚本都正确运行)之后,IE8 拒绝执行和网络连接(我已经用 Fiddler2 检查过)并简单地无限地显示“正在加载”图标。此阶段唯一的解决方法是关闭并打开浏览器本身。
我正在使用 JQuery 和 php。

这是我的初始化代码:

    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

最佳答案

经过长时间的搜索,我在另一个论坛中找到了答案。我将其发布在这里是为了其他可能遇到相同情况的开发者的利益。

<小时/>

嗨,

我也遇到了同样的问题。在 HTML 正文的卸载事件上中止 AJAX 请求解决了该问题。

var activeRequest = null;

var atmosphere_result = function(src) {
activeRequest = null;
$("#content").html(src);//update div content
}

var atmosphere = function() {
activeRequest = $.ajax({
type:"GET",
cache:false,
url:'/atmosphere',
success: atmosphere_result
});
};

$(window).unload(function() {
if (activeRequest)
activeRequest.abort();
});

@Jeanfrancois:我认为在新的 jQuery 插件中自动执行此操作是个好主意。

HTH,马蒂亚斯·赖施巴赫

关于internet-explorer - IE8在5次长轮询请求后停止网络访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7175005/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com