Jquery 带有基本身份验证的JSONP.ajax请求
我试图从需要基本身份验证的外部API请求JSONP输出。我有下面的代码来访问它:Jquery 带有基本身份验证的JSONP.ajax请求,jquery,jsonp,basic-authentication,Jquery,Jsonp,Basic Authentication,我试图从需要基本身份验证的外部API请求JSONP输出。我有下面的代码来访问它: $.ajax({ url: "https://api.example.com/photos/highest-rated?gender=f", dataType: "jsonp", beforeSend: function(xhr) { xhr.setRequestHeader("Authentication", $.base64.encode(device_id + "
$.ajax({
url: "https://api.example.com/photos/highest-rated?gender=f",
dataType: "jsonp",
beforeSend: function(xhr) {
xhr.setRequestHeader("Authentication",
$.base64.encode(device_id + ":" + secret_key));
},
success: function(json) {
alert('works');
},
error: function (jqXHR, textStatus, errorThrown) {
alert (textStatus);
alert (errorThrown);
}
由此产生的错误有:
textStatus = "parsererror"
errorThrown = "Error: jQuery18306713019642047584_1367530194009 was not called"
我将此jQuery插件用于Base64编码:
有人知道我做错了什么吗?可能是重复的