使用ajax访问delicious api时出现问题
-
20-09-2019 - |
题
我正在使用以下 jQuery 代码来尝试访问美味的 api,但它不起作用。如果我直接在浏览器中访问 api url,它会按预期返回 xml,因此 url 是正确的。
有人知道发生了什么吗?可能是 https,但 jQuery 文档没有明确禁止这样做。
$(document).ready(function(){
$.ajax({
type: 'GET',
dataType: 'xml',
url:"https://api.del.icio.us/v1/posts/dates",
success: function(response) {
console.log(response);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
console.log(textStatus);
console.log(errorThrown);
}
});
});
编辑:
我收到“数据为空”错误,如果我设置数据,该错误仍然会发生:'',并且在第一次尝试访问浏览器中的页面时,系统会提示我输入用户名和密码,这似乎是像我包含带有 href="https://api.del.icio.us/ 的标签一样存储的v1/posts/dates”在头部它下载文件确定
解决方案
正如先生。Sanchez 指出,您无法从域中托管的页面向该 API 发出 XMLHttpRequest。
也许他们有 JSONP 版本的 API。
不隶属于 StackOverflow