I am trying to access some RESTful services that run under basic Apache preemtive authentication. I use jquery Ajax and send the user and password with the header "Authentication". However, my request triggers an empty error every time.
Here is the full call to $ .ajax:
$.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 am I doing wrong? Is there something that I ignore here? Thanks.
source share