当我试图从另一个站点获取JSON数据并解析它时,我收到了一个错误消息:
跨源读取阻塞(CORB)阻止跨原点响应http://a-url与MIME类型的应用程序/json。有关更多详细信息,请参阅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阻止了我这样做。
发布于 2019-04-09 08:29:18
是的,这是Chrome的新产品。您需要将Ajax查询移到后台脚本。
您将在本主题中找到如何做到这一点:How to stop CORB from blocking requests to data resources that respond with CORS headers?
https://stackoverflow.com/questions/53898468
复制相似问题