什么会导致页面被取消?我有一个Chrome开发者工具的截图。
这种情况经常发生,但不是每次都发生。似乎一旦缓存了一些其他资源,页面刷新就会加载LeftPane.aspx。真正奇怪的是,这只发生在谷歌Chrome浏览器中,而不是ie8。知道为什么Chrome会取消一个请求吗?
什么会导致页面被取消?我有一个Chrome开发者工具的截图。
这种情况经常发生,但不是每次都发生。似乎一旦缓存了一些其他资源,页面刷新就会加载LeftPane.aspx。真正奇怪的是,这只发生在谷歌Chrome浏览器中,而不是ie8。知道为什么Chrome会取消一个请求吗?
当前回答
status= cancelled也可能发生在JavaScript事件的ajax请求上:
<script>
$("#call_ajax").on("click", function(event){
$.ajax({
...
});
});
</script>
<button id="call_ajax">call</button>
事件成功发送请求,但随后被取消(但由服务器处理)。原因是,元素在单击事件时提交表单,无论您是否对同一单击事件发出任何ajax请求。
为了防止请求被取消,JavaScript event.preventDefault();必须被称为:
<script>
$("#call_ajax").on("click", function(event){
event.preventDefault();
$.ajax({
...
});
});
</script>
其他回答
我也遇到过同样的问题,在我们的代码深处,我们有这样的伪代码:
创建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
当我在样式表中嵌入web字体时,我已经嵌入了所有类型的字体以及woff, woff2, ttf。最近我注意到Chrome取消请求ttf和woff时,woff2是存在的。我现在使用Chrome版本66.0.3359.181,但我不确定Chrome什么时候开始取消额外的字体类型。
Chrome版本33.0.1750.154米一致取消图像加载,如果我使用移动仿真指向我的本地主机;特别是用户代理欺骗(相对于屏幕设置)。
当我关闭用户代理欺骗时;图像请求没有被取消,我看到了图像。
我仍然不明白为什么;在前一种情况下,当请求被取消时,请求头(注意:显示的是临时头)只有
接受 cache - control 编译指示 推荐人 用户代理
在后一种情况下,所有这些因素加上其他因素,比如:
饼干 连接 宿主 接受编码 接收语言
耸耸肩
当我通过JavaScript重定向时,我在Chrome中得到了这个错误:
<script>
window.location.href = "devhost:88/somepage";
</script>
如你所见,我忘记了'http://'.在我添加它之后,它起作用了。
这是chrome取消请求的另一个例子,我刚刚遇到过,上面的答案中没有提到。
简单地说 我的android手机上的自签名证书不受信任。
细节 我们正处于开发/调试阶段。url指向自签名主机。代码是这样的:
location.href = 'https://some.host.com/some/path'
Chrome只是默默地取消了请求,没有给像我这样的web开发新手留下任何线索来解决这个问题。一旦我使用android手机下载并安装了证书,问题就消失了。