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