如何使用 jQuery 或 node.js 对 json 文件进行异步跨域请求(GET)?我有我的 api,我只需要向文件发出请求
$.ajax({
type: 'GET',
url: "https://api.flightstats.com/flex/airports/rest/v1/json/active?appId=3a311b8b&appKey=5d67203e8afab7fe8d01e0debf177171",
processData: true,
data: {},
dataType: "json"
});
结果
XMLHttpRequest
XMLHttpRequest cannot load https://api.flightstats.com/flex/airports/rest/v1/json/active?appId=3a311b8b&appKey=5d67203e8afab7fe8d01e0debf177171. Origin https://developer.flightstats.com is not allowed by Access-Control-Allow-Origin.
或者
$.ajax({
type: 'GET',
url: "https://api.flightstats.com/flex/airports/rest/v1/json/active?appId=3a311b8b&appKey=5d67203e8afab7fe8d01e0debf177171?callback?",
processData: true,
data: {},
dataType: "jsonp"
});
结果
undefined