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

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


当前回答

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

其他回答

另一件要注意的事情可能是AdBlock扩展,或一般的扩展。

但“很多”人有AdBlock....

为了排除扩展,以隐身方式打开一个新标签,确保你想测试的扩展“允许隐身”是关闭的。

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

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

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

我们遇到(取消)状态的另一个地方是在特定的TLS证书错误配置中。如果一个网站(例如https://www.example.com)配置错误,导致证书不包括www。但有效的https://example.com, chrome将取消此请求,并自动重定向到后者的网站。Firefox则不是这样。

当前有效的示例:https://www.pthree.org/

I had the same issue when updating a record. Inside the save() i was prepping the rawdata taken from the form to match the database format (doing a lot of mapping of enums values, etc), and this intermittently cancels the put request. i resolved it by taking out the data prepping from the save() and creating a dedicated dataPrep() method out of it. I turned this dataPrep into async and await all the memory intensive data conversion. I then return the prepped data to the save() method that i could use in the http put client. I made sure i await on dataPrep() before calling the put method:

等待dataToUpdate =等待dataPrep(); http。把(apiUrl dataToUpdate);

这解决了间歇性取消请求的问题。

对于我的案例,我有一个锚与点击事件像

<a href="" onclick="somemethod($index, hour, $event)">

里面点击事件我有一些网络呼叫,Chrome取消请求。锚有href与""意味着,它重新加载页面,同时它有点击事件与网络调用被取消。每当我用void替换href时

<a href="javascript:void(0)" onclick="somemethod($index, hour, $event)">

问题消失了!