IE8在5个长轮询请求后停止网络访问

我在我的系统中使用Long Polling作为推送机制。 它在Firefox和Chrome中运行良好,但在IE8中行为很奇怪:它加载OK 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,Matthias Reischbacher