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

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


当前回答

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

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

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

其他回答

你可能想要检查“X-Frame-Options”标题标签。如果它设置为SAMEORIGIN或DENY,那么iFrame插入将被Chrome(和其他浏览器)根据规范取消。

另外,注意一些浏览器支持ALLOW-FROM设置,但Chrome不支持。

为了解决这个问题,你需要删除“X-Frame-Options”标题标签。这可能会让你容易受到点击劫持攻击,所以你需要决定风险是什么以及如何减轻它们。

我在div标签里面有一个a标签。div有onclick="location='http://mydestination.org/'"和一个标签在href中有相同的URL。这导致目标页面被加载两次,第一次加载被Chrome取消。

从严格的Angular角度来看:

当你不能在代码层面上正确地中断时,就会发生这种情况。

假设request1出来了,它的响应也是, 在那之后,嵌套的request2也出去了,它的响应也来了,我们直接打破了循环,没有正确地破坏request1的订阅,

在那个时候,它发生了

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

创建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

在我的情况下,它开始出现后chrome 76更新。

由于一些问题在我的JS代码,窗口。位置被多次更新,导致取消先前的请求。 虽然这个问题之前就存在,但chrome在更新到版本76后开始取消请求。