[jQuery] HTTP Authorization

[jQuery] HTTP Authorization


Hi,
I am trying to use $.getJSON to get a JSON feed but I am failing on an
authorization part and I keep getting a uername and password box when
running the page.
I have tried creating an authorize object and then passing this as
data in the second argument of the getJSON method like this:
var authInfo = "myusername:myPassword";
var authInfoBaseEncoded = btoa(authInfo);
var myAuthObj = {
Authorisaztion:authInfoBaseEncoded
}
$.getJSON("urlhere", myAuthObj, function() {
//do something fun here
});
But this is not working and I still keep getting the username/password
prompt when running my test page.
I also tried using $.ajax instead like this:
var authInfo = "myusername:myPassword";
var authInfoBaseEncoded = btoa(authInfo);
$.ajax({
url: "urlhere",
dataType: "json",
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", authString64);
},
success: function() {
//do something fun here
}
});
But this doesn't even get me as far as the auth prompt and I get a
'Access to restricted URl denied' message in firebug
Can anyone help?