I get a 303 response with a location header, how can I prevent XMLHttpRequest from redirecting?
Below is the code
var xhr = new XMLHttpRequest();
xhr.open('GET', '/api/v1/test' + $(e.target).data('machineimage'));
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
// here I need to get the `location` header and do something with it
// xhr.getResponseHeader('location')
// but before it reaches here, there is a redirect
}
};
xhr.send();
I observed its the same with jquery as well, is there anyway to bypass this?