【发布时间】:2021-02-07 18:46:18
【问题描述】:
我有 Json 格式的 WordPress 提要 (https://blog.piscessportfishing.com/feed/json/),但我无法使用 ajax 请求来阅读它。 成功我没有得到任何数据变量。相反,它会在警报中给出错误。
这是我的代码:
$.ajax({
type: 'GET',
url: "https://blog.piscessportfishing.com/feed/json/",
dataType: 'json',
data: {},
success: function(data) {
console.log(data);
},
error: function (Request, textStatus, errorThrown) {
alert("Request=" + Request.responseText + "\ntextStatus=" + textStatus + "\nerrorThrown=" + errorThrown);
}
});
【问题讨论】:
-
您是否有任何CORS错误,这意味着您无法访问其他域URL?仅供参考,您应该为所有类型的请求添加标头,它应该是一个正确的结构
-
@HemaRamasamy 是的,问题出在 CORS 上,感谢您的帮助。