我正在使用以下 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" 的标签它可以下载文件