var username = 'xxxx';
var password = 'zzzz';
var xmlstring="<root><request><AADHAAR_ID>aaaaaaa</AADHAAR_ID><NAME>hhhhhhh</NAME><DOB></DOB><MOBILENO></MOBILENO><FLAG>QVVUSA==</FLAG><RESPONSE_CODE></RESPONSE_CODE><ERROR_CODE></ERROR_CODE><OTP></OTP><PIN></PIN><DEPT>aswww</DEPT><VENDORID>MTAwSFBN</VENDORID></request></root>";
function make_base_auth(username, password) {
var tok = username + ':' + password;
var hash = btoa(tok);
return "Basic " + hash;
}
$.ajax({
type: "POST",
async: true,
dataType:"xml",
contentType: "application/xml",
url: 'http://test/test/test?reqXml='+xmlstring,
beforeSend: function (xhr){
xhr.setRequestHeader('Authorization', make_base_auth(username, password));
},
success: function(){console.log('success');
alert('success');
},
error: function(data) {console.log('error');
console.log(data);
}
});
Hi, above is my code please tell what i have missed.I'm attempting to do a simple PSTrequest from my local server and this request requires an Authorization header in order to function correctly. I have performed the POST request and retrieved the data successfully in Postman, Ajax results in a "Invalid HTTP status code 302" error and My error is XMLHttpRequest cannot load .....Response for preflight is invalid (redirect)