I have a code which tries to post to a api. But I keep getting 401 in firefox and 400 in safari
$.ajax({
type: "POST",
url: "http://url.com",
dataType: "json",
async: "false",
data: form_data,
beforeSend: function(xhr1) {
xhr1.setRequestHeader("Authorization", "Basic " + encodeBase64(username + ":" + password))
},
success: function (data,status,xhr){
//do something
}
});
I followed instructions from here http://dothow.blogspot.com/2009/05/http-basic-authentication-with-jquery.html?showComment=1270999665472#c3021624182011440325
*encodeBase64 is part of a library function
usernameandpasswordproperties of$.ajax? api.jquery.com/jQuery.ajaxError: uncaught exception: [Exception... "Success arg 1 [nsIDOMDocumentXBL.getBindingParent]" nsresult: "0x0 (NS_OK)" location: "JS frame :: chrome://global/content/bindings/tree.xml :: onxblunderflow :: line 947" data: no]and safari the same 400 bad request