【跨域报错解决方案】Access to XMLHttpRequest at ‘http://xxx.com/xxx‘ from origin

in Wordpress with 0 comment

  在使用了wordpress某个主题后,发现有一个错误:

Access to XMLHttpRequest at ‘http://xxxx.com/xxx’ from origin ‘null’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

如图:
Access to XMLHttpRequest at.jpg
解决方法:
在主题目录下搜索

$.ajax({
        url:riprov2.admin_url,
        dataType:'json',
        type:'POST',
        async: false,
        data: formData,
    });

把dataType的json改为jsonp

$.ajax({
        url:riprov2.admin_url,
        dataType:'jsonp',//这里json改为jsonp
        type:'POST',
        async: false,
        data: formData,
    });
Responses
2016lengh.gif2016kun.gif2016db.gif2016baojin.gif2016jk.gif2016kb.gif2016qq.gif2016zj.gif2016qiao.gif2016am.gif2016kk.gif2016qd.gif2016gg.gif2016lh.gif2016wq.gif2016gz.gif2016zhh.gif2016ll.gif2016shuai.gif2016kel.gif2016zk.gif