我在ajax调用中遇到CORS问题,但我也警告不要重定向到URL。
错误:
jquery-1.10.2.min.js:6跨域读取阻止(CORB)阻止了MIME类型为text / html的跨域响应“重定向url”。有关更多详细信息,请参见chromestatus.com/feature/5629709824032768。
我的代码:
$.ajax({
url: 'here are url',
dataType: 'JSONP',
headers: {
'Set-Cookie': 'Secure;SameSite=none;',
'Access-Control-Allow-Origin': '*',
},
jsonpCallback: 'callbackFnc',
type: 'GET',
async: false,
crossDomain: true,
contentType: 'text/html;charset=utf-8',
success: function (data) {
debugger;
},
failure: function (data) {
debugger;
},
complete: function (data) {
debugger;
if (data.readyState == '4' && data.status == '200') {
console.log("success")
}
else {
console.log("failed")
}
}
});
我认为您的标头向后,为JS服务的服务器应具有响应标头:
Access-Control-Allow-Origin': '*'
这不属于请求标题。