调用同步xmlhtt prequest当IE挂5分钟xmlhtt、prequest、IE

由网友(可以哭但决不认输)分享简介:我有一个Web应用程序和使用AJAX回调到我的网络服务器来获取数据。I have a web application and use ajax to call back to my webserver to fetch data.有时(在相当未predictable的时刻,但它可以再现)的IE挂起完全进行5分钟(窗...

我有一个Web应用程序和使用AJAX回调到我的网络服务器来获取数据。

I have a web application and use ajax to call back to my webserver to fetch data.

有时(在相当未predictable的时刻,但它可以再现)的IE挂起完全进行5分钟(窗口说没有响应),然后回来和xmlhtt prequest对象响应误差12002。

Sometimes(at rather unpredictable moments, but it can be reproduced) IE hangs completely for 5 minutes(the window says Not Responding) and then comes back and the xmlhttprequest object responds with error 12002.

的办法,我可以重现如下:

The way I can reproduce it is as follows.

从使用按钮返回主窗口(A)打开窗口(B) 在窗口A调用同步AJAX(PROC1)时,点击打开窗口B. PROC1运行文件按钮。 新窗口(B)具有AJAX code(PROC2),并调用服务器同步。运行正常 在用户关闭窗口后B PROC2完成,但之前返回数据。 在主窗口(一)用户再次点击按钮。 PROC1再次运行,但现在5分钟发送()的调用块。

请帮忙。我一直在找了3天。

Please help. I've been looking for 3 days.

请注意: *我无法在Firefox测试(应用程序不兼容火狐) * 我有无使用同步调用(这是应用程序的构造方式,它需要太多的开发者的努力改写吧)

Please note: * I can't test it in firefox (the app is not firefox compatible) * I have to use synchronous calls (that's the way the app is constructed and it would take too much developer effort to rewrite it)

为什么会出现这种情况,如何解决这个问题?

Why does this happen and how to I fix this?

推荐答案

您说的对夏侯,这是关系到Internet Explorer的连接2.限制出于某种原因,IE不会释放连接AJAX请求在封闭进行窗口。

You're right Jaap, this is related to Internet Explorer's connection limit of 2. For some reason, IE doesn't release connections to AJAX requests performed in closed windows.

我有一个非常类似的情况,只是稍微简单:

I have a very similar situation, only slightly simpler:

在用户点击一个窗口,打开窗口B中 在窗口B执行一个Ajax调用需要一段时间 在Ajax调用返回之前,用户关闭窗口B.本叫泄漏的连接。 在重复1更多的时间,直到两个可用的连接泄露 在浏览器变得反应迟钝

一种方法,你可以尝试这似乎工作(在您发现文中提到的)是中止在页面的unload事件XMLHTTP请求。​​

One technique you can try (mentioned in the article you found) that does seem to work is to abort the XmlHttp request in the unload event of the page.

所以是这样的:

var xhr = null;

function unloadPage() {
  if( xhr !== null ) {
    xhr.abort();
  }
}

另一种选择是使用同步AJAX调用,这将阻塞,直到调用返回时,实质上是在锁定的浏览器。这可能会或可能不会被接受给你的特殊情况。

Another option is to use synchronous AJAX calls, which will block until the call returns, essentially locking the browser. This may or may not be acceptable given your particular situation.

// the 3rd param is whether the call is asynchronous
xhr.open( 'get', 'url', false );

最后,如其他地方提到,可以调整连接IE使用在注册表中的最大数量。期待您站点的访问者但是要做到这一点是不现实的,也不会真正解决问题 - 的发生只是推迟了。作为一个侧面说明,IE8会允许6个并发连接。

Finally, as mentioned elsewhere, you can adjust the maximum number of connections IE uses in the registry. Expecting visitors to your site to do this however isn't realistic, and it won't actually solve the problem -- just delay it from happening. As a side-note, IE8 is going to allow 6 concurrent connections.

阅读全文

相关推荐

最新文章