什么会导致页面被取消?我有一个Chrome开发者工具的截图。

这种情况经常发生,但不是每次都发生。似乎一旦缓存了一些其他资源,页面刷新就会加载LeftPane.aspx。真正奇怪的是,这只发生在谷歌Chrome浏览器中,而不是ie8。知道为什么Chrome会取消一个请求吗?


当前回答

我也遇到过同样的问题,在我们的代码深处,我们有这样的伪代码:

创建iframe 加载iframe提交一个表单 2秒后,移除iframe

thus, when the server takes more than 2 seconds to respond the iframe to which the server was writing the response to, was removed, but the response was still to be written , but there was no iframe to write , thus chrome cancelled the request, thus to avoid this I made sure that the iframe is removed only after the response is over, or you can change the target to "_blank". Thus one of the reason is: when the resource(iframe in my case) that you are writing something in, is removed or deleted before you stop writing to it, the request will be cancelled

其他回答

这是发生在我身上的事情:服务器为302重定向返回了一个格式错误的“Location”头。 当然,Chrome没有告诉我这一点。我在firefox中打开了这个页面,并立即发现了问题。 有多种工具真好:)

以我为例,我发现它是jquery的全局超时设置,一个jquery插件设置全局超时为500ms,这样当请求超过500ms时,chrome就会取消请求。

当我通过JavaScript重定向时,我在Chrome中得到了这个错误:

<script>
    window.location.href = "devhost:88/somepage";
</script>

如你所见,我忘记了'http://'.在我添加它之后,它起作用了。

当我用$调用a. js文件时,也发生了同样的情况。ajax,并发出一个ajax请求,我所做的是正常调用。

如果您使用axios,它可以帮助您

// change timeout delay: Instance.defaults.timeout = 2500;

https://github.com/axios/axios#config-order-of-precedence