Chrome新版本73.0.3683.75的Ajax调用错误? [英] Ajax call bug with Chrome new version 73.0.3683.75?
问题描述
在更新Chrome之前,我的代码运行正常。
My code was working fine before the Chrome update.
我对服务器进行了ajax调用。我的服务器收到呼叫,将JSON返回给客户端,但是答案始终为空。当我查看Fiddler时,会从服务器得到答复。
I make an ajax call to my server. My server receives the call, returns JSON to the client, but the answer is always empty. When I look in Fiddler I get an answer from the server.
我尝试使用JQuery,也尝试使用xmlhttp调用。总是相同的结果
I try with JQuery, and I also try with an xmlhttp call. Always the same result
是否应用了新的CORS策略规则??
Did new CORS policy rules apply...?
有我的xmlHTTP调用
There is my xmlHTTP call
var xmlhttp = new XMLHttpRequest(); // new HttpRequest instance
var theUrl = "URL";
xmlhttp.open("POST", theUrl);
xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xmlhttp.send('{ "args" :{ "Obj":"my obj"}}');
xmlhttp.onreadystatechange = function(state,xhh,aaa){
if (xmlhttp.readyState == XMLHttpRequest.DONE) {
alert(xmlhttp.responseText);
}
}
ajax调用类似
$.ajax({
url: "URL",
data: '{ "args" :{ "Obj":"my obj"}}',
dataType: "json",
contentType: "application/json; charset=utf-8",
type: "POST",
async: false,
error: function (xhr, ajaxOptions, thrownError) {
if (that.Fail != null) {
that.Fail();
}
},
success : function(data){
alert(data);
}
})
推荐答案
升级到Chrome 73后,我遇到了同样的问题。感谢@wOxxOm
I had the same problem after upgrade to Chrome 73. Thanks to @wOxxOm
这是到目前为止的解决方法:
This is the workaround until now:
- 转到chrome:// flags
- 禁用启用网络服务
- Go to chrome://flags
- Disabled the Enable network service
更新:
根据此公告,这不是错误: https://www.chromium.org/Home/chromium- security / extension-content-script-fetches
This is not a bug, according to this announcement: https://www.chromium.org/Home/chromium-security/extension-content-script-fetches
您需要将跨域提取放置到背景脚本中,而不是内容脚本中。
You will need to put the Cross-Origin Fetches to the background script instead of the content script.
这篇关于Chrome新版本73.0.3683.75的Ajax调用错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!