具有基本身份验证的JSONP .ajax请求

时间:2013-05-02 21:32:06

标签: 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 + ":" + 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编码:https://github.com/carlo/jquery-base64

有谁知道我做错了什么?

0 个答案:

没有答案
相关问题