Chrome 新版本 73.0.3683.75 的 Ajax 调用错误? [英] Ajax call bug with Chrome new version 73.0.3683.75?

查看:21
本文介绍了Chrome 新版本 73.0.3683.75 的 Ajax 调用错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码在 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

这是目前的解决方法:

  1. 转到 chrome://flags
  2. 禁用启用网络服务

更新:

根据此公告,这不是错误: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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆