ajax 请求丢失,Ajax请求挂在Chrome浏览器后连接丢失
如果我们发送POST Ajax请求时,有没有网络连接,我们得到的控制台err_internet_disconnected异常(和我认为,这是确定)
如果我们给长岗Ajax请求,失去这个请求,谷歌Chrome不会中止它,就在控制台和devconsole的网络选项卡中没有err_internet_disconnected外,这个请求被标记为未决期间的网络连接(即使连接出现)。事实上,这个连接挂起,没有机会在js代码中处理这个(我们希望得到ajax错误,但没有任何反应)。
你有什么建议,如何处理这个问题?
编辑: 的代码示例:
$.ajax({
url: "https://someserver.com/ws.asmx/ExecuteEx?pureJson",
type: "POST",
contentType: "application/json",
data: data,
success: function() {
console.log("success");
},
error: function() {
console.log("error");
}
})
2017-10-11
SkillZ
+0
您可以发布您的Ajax代码? –
+0
@DiskJunky,是的,我已经编辑这篇文章 –
+0
你有没有设置timeout财产?查看[为Ajax设置超时(jQuery)](https://stackoverflow.com/questions/5225597/set-timeout-for-ajax-jquery)。如果超时过期后连接丢失,应该中止请求。你有没有测试任何其他浏览器如FireFox或IE? –
如果我们发送POST Ajax请求时,有没有网络连接,我们得到的控制台err_internet_disconnected异常(和我认为,这是确定) 如果我们给长岗Ajax请求,失去这个请求,谷歌Chrome不会中止它,就在控制台和devconsole的网络选项卡中没有err_internet_disconnected外,这个请求被标记为未决期间的网络连接(即使连接出现)。事实上,这个连接挂起,没有机会在js代码中处理这个(我们希望得到ajax错误,但没有任何反应)。 你有什么建议,如何处理这个问题? 编辑: 的代码示例: $.ajax({ url: "https://someserver.com/ws.asmx/ExecuteEx?pureJson", type: "POST", contentType: "application/json", data: data, success: function() { console.log("success"); }, error: function() { console.log("error"); } }) 2017-10-11 SkillZ +0 您可以发布您的Ajax代码? – +0 @DiskJunky,是的,我已经编辑这篇文章 – +0 你有没有设置timeout财产?查看[为Ajax设置超时(jQuery)](https://stackoverflow.com/questions/5225597/set-timeout-for-ajax-jquery)。如果超时过期后连接丢失,应该中止请求。你有没有测试任何其他浏览器如FireFox或IE? –