【问题标题】:Problems with CORBCORB 的问题
【发布时间】:2019-05-22 17:36:35
【问题描述】:

我正试图从另一个站点获取 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 阻止了我这样做。

【问题讨论】:

标签: javascript json


【解决方案1】:

是的,这是 Chrome 的新功能。您需要将 Ajax 查询移至后台脚本。

您将在本主题中找到如何做到这一点:How to stop CORB from blocking requests to data resources that respond with CORS headers?

【讨论】:

    猜你喜欢
    • 2020-06-06
    • 1970-01-01
    • 2020-09-30
    • 2019-12-12
    • 2019-03-14
    • 1970-01-01
    • 1970-01-01
    • 2019-06-21
    • 2018-12-17
    相关资源
    最近更新 更多