使用API在JavaScript中获取数据,但会出现此错误
跨域读取阻止(CORB)阻止了MIME类型为application / json的跨域响应https://MYURL/admin/orders.json?callback=jQuery33108579100223062108_1529487937348&_=1529487937349。有关更多详细信息,请参见https://www.chromestatus.com/feature/5629709824032768。
这是我的代码
var settings = {
"async": true,
"crossDomain": true,
"dataType": "JSONP",
"url": "myurl",
"method": "GET",
"headers": {
"Access-Control-Allow-Credentials": true,
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET",
"Access-Control-Allow-Headers": "Content-Type",
"authorization": "Basic ZGNlMzFjMzNkMDJlY2RiZjsdfdsfIxNjc6YzNhYzssdfsdfdfsdfMTU1ZDk4ZGM=",
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
注意:在PHP CURL请求中,一切正常。