我得到一个带有位置标题的303响应,如何防止XMLHttpRequest重定向?
以下是代码
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();
我对jquery的观察结果也是如此,无论如何都要绕过它?