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

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


当前回答

其中一个原因可能是XMLHttpRequest.abort()在代码中某处被调用,在这种情况下,请求将在Chrome开发工具网络选项卡中具有取消状态。

其他回答

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);

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

对于任何来自LoopbackJS并试图使用图表示例中提供的自定义流方法的人。我使用PersistedModel得到这个错误,切换到基本模型修复了我的事件源状态取消的问题。

同样,这是专门针对环回api的。既然这是谷歌上的顶级答案,我想我应该把这个放在混合答案中。

其中一个原因可能是XMLHttpRequest.abort()在代码中某处被调用,在这种情况下,请求将在Chrome开发工具网络选项卡中具有取消状态。

我们曾遇到过类似的问题,Chrome会取消在帧内或iframes内加载内容的请求,但只是间歇性的,这似乎取决于计算机和/或互联网连接的速度。

这些信息已经过时几个月了,但是我从头开始构建了Chromium,在源代码中挖掘了所有可以取消请求的地方,并在所有这些地方设置了断点以进行调试。根据记忆,Chrome会取消请求的地方只有:

The DOM element that caused the request to be made got deleted (i.e. an IMG is being loaded, but before the load happened, you deleted the IMG node) You did something that made loading the data unnecessary. (i.e. you started loading a iframe, then changed the src or overwrite the contents) There are lots of requests going to the same server, and a network problem on earlier requests showed that subsequent requests weren't going to work (DNS lookup error, earlier (same) request resulted e.g. HTTP 400 error code, etc)

在我们的例子中,我们最终追踪到一个试图将HTML附加到另一个帧的帧,这有时发生在目标帧加载之前。一旦您接触到iframe的内容,它就不能再将资源加载到其中(它如何知道将资源放在哪里?),因此它会取消请求。

我在加载300张图片作为背景图片时遇到了这种情况。我猜一旦第一个超时,它就会取消所有其他的,或者达到最大并发请求。需要一次实现5个