跨域错误提示:Access to XMLHttpRequest at ‘A‘ from origin ‘B‘ has been blocked by CORS policy

原因:跨域请求从://b/xxx

错误:Access to XMLHttpRequest at 'A' from origin 'B' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

原本代码:

$.ajax({type: "GET",url: url_B,timeout: 3000,success: function(msg) {console.log(msg);},
});

为了跨域需要设置参数crossDomain和dataType。

修正后的代码:

$.ajax({type: "GET",url: url_B,crossDomain:true,dataType: 'jsonp',timeout: 3000,success: function(msg) {console.log(msg);},
});

问题解决