I am trying to request a JSONP output from an external API that requires basic authentication. I have the code below to access it:
$.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);
}
The resulting errors are:
textStatus = "parsererror"
errorThrown = "Error: jQuery18306713019642047584_1367530194009 was not called"
I'm using this jQuery plugin for the Base64 encoding: https://github.com/carlo/jquery-base64.
Does anyone know what I'm doing wrong?