from origin 'null' has been blocked by CORS policy: Cross origin requests [duplicate]

随声附和 提交于 2021-02-08 04:49:57

问题


This error occurred while calling up JSON. I don't know why this error is happening.

$.getJSON(url, function(data){
    console.log(data);
});

Error:

Access to XMLHttpRequest at (this is JSON URL) from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

回答1:


The error message says it all. You are apparently accessing the page running this script with a protocol scheme other than the several supported for cross-origin requests. This would happen commonly if you are, say, executing a local file in your browser via the file:// protocol and trying to access some URL on the Internet in your $.getJSON call.



来源:https://stackoverflow.com/questions/55252192/from-origin-null-has-been-blocked-by-cors-policy-cross-origin-requests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!