I am trying to reach some RESTful services that are running under Apache preemtive basic authentication. I am using jquery Ajax, and sending the user and password with the 'Authentication' header. However, my request is throwing an empty error every time it runs.
Here is the full $.ajax call:
$.ajax({
cache:false,
url: urladdress,
type:'GET',
async:false,
headers: { "cache-control": "no-cache" },
dataType: "html", //or xml or json
contentType: "html",
beforeSend : function(req)
{
req.setRequestHeader('Authorization', "Basic " + base64string); //user:password);
},
success: function(data){
successcallback(data);
},
error: function(xhRequest, ErrorText, thrownError){
alert("ERROR: "+ JSON.stringify(xhRequest));
},
complete: function(result){
...
}
});
What I am doing wrong? Is there something that I am ignoring here? Thanks.