我遇到了这个代码的麻烦,我似乎无法让它工作。我为此调用返回的典型错误是“无法加载资源:服务器响应的状态为401(未授权)”。跨域jQuery ajax调用不起作用
$('#btnZendesk').click(function() {
$.ajax({
url: "https://flatlandsoftware.zendesk.com/api/v2/topics/22505987.json",
type: 'GET',
crossDomain: true,
xhrFields: {
withCredentials: true
},
cache: false,
dataType: 'jsonp',
processData: false,
data: 'get=login',
timeout: 2000,
username: "[email protected]",
password: "test",
success: function (data, textStatus, response) {
alert("success");
},
error: function (data, textStatus, response) {
alert(data);
}
});
同源策略不会允许你做跨域AJAX请求。 – gronostaj
https://flatlandsoftware.zendesk.com/api/v2/topics/22505987.json资源受基本认证保护 – Tom
错误的密码和用户名? – JJJ