当我遇到错误
时,我正试图获取JSON数据并从另一个站点解析它。跨域读取阻止(CORB)阻止了MIME类型为application / json的跨域响应http://a-url。有关更多详细信息,请参见https://www.chromestatus.com/feature/5629709824032768。
function fetchdata() {
// Replace ./data.json with your JSON feed
fetch('[some-url-with-CORB]').then(response => {
return response.json();
}).then(data => {
// Work with JSON data here
console.log(data);
}).catch(err => {
// Do something for an error here
});
}
我打算获取JSON响应,然后从那里解析它,但是CORB阻止了我这样做。
答案 0 :(得分:0)
是的,这是Chrome的新功能。您需要将Ajax查询移至后台脚本。
在本主题中,您将找到如何做的事情:How to stop CORB from blocking requests to data resources that respond with CORS headers?