什么会导致页面被取消?我有一个Chrome开发者工具的截图。
这种情况经常发生,但不是每次都发生。似乎一旦缓存了一些其他资源,页面刷新就会加载LeftPane.aspx。真正奇怪的是,这只发生在谷歌Chrome浏览器中,而不是ie8。知道为什么Chrome会取消一个请求吗?
什么会导致页面被取消?我有一个Chrome开发者工具的截图。
这种情况经常发生,但不是每次都发生。似乎一旦缓存了一些其他资源,页面刷新就会加载LeftPane.aspx。真正奇怪的是,这只发生在谷歌Chrome浏览器中,而不是ie8。知道为什么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);
这解决了间歇性取消请求的问题。
其他回答
在这能帮助任何人,我遇到取消状态时,我省略了返回false;在表单中提交。这导致ajax发送之后立即紧跟提交操作,这将覆盖当前页面。代码如下所示,在末尾返回重要的false。
$('form').submit(function() {
$.validator.unobtrusive.parse($('form'));
var data = $('form').serialize();
data.__RequestVerificationToken = $('input[name=__RequestVerificationToken]').val();
if ($('form').valid()) {
$.ajax({
url: this.action,
type: 'POST',
data: data,
success: submitSuccess,
fail: submitFailed
});
}
return false; //needed to stop default form submit action
});
希望这能帮助到别人。
当我用$调用a. js文件时,也发生了同样的情况。ajax,并发出一个ajax请求,我所做的是正常调用。
对我来说,这是一条错误的道路。我建议调试的第一步是看看你是否可以加载文件独立的ajax等。
对我来说,“取消”状态是因为文件不存在。奇怪为什么chrome浏览器不显示404。
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);
这解决了间歇性取消请求的问题。