【发布时间】:2020-10-08 20:20:06
【问题描述】:
对于一个白人,我正在处理一个 api 问题,但总是面临这个问题并且找不到任何解决方案。 这是我的ajax请求
$(document).ready(function() {
var url = 'https://www.xeno-canto.org/api/2/recordings?query=bearded+bellbird';
$.ajax({
url: url,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
type: "GET",
dataType: "json",
data: {},
success: function(result) {
console.log(result);
},
error: function() {
console.log("error");
}
});
});
但在 chrome 控制台中会显示此结果
从源“https://www.birdpx.com”访问“https://www.xeno-canto.org/api/2/recordings?query=Greater+Scaup”处的 XMLHttpRequest 已被 CORS 策略阻止:请求的资源上不存在“Access-Control-Allow-Origin”标头。
你有什么办法吗?
【问题讨论】:
标签: javascript jquery json ajax api