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

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


当前回答

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

其他回答

这是chrome取消请求的另一个例子,我刚刚遇到过,上面的答案中没有提到。

简单地说 我的android手机上的自签名证书不受信任。

细节 我们正处于开发/调试阶段。url指向自签名主机。代码是这样的:

location.href = 'https://some.host.com/some/path'

Chrome只是默默地取消了请求,没有给像我这样的web开发新手留下任何线索来解决这个问题。一旦我使用android手机下载并安装了证书,问题就消失了。

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

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

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

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

问题消失了!

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

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

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

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

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

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