是否可以发送xhr HTTP HEAD请求来仅为第一个请求获取标头响应,而不是像重定向那样自动跟随301,302?我只对获取网址的新位置感兴趣。例如:XHR HEAD请求是否有可能不遵循重定向(301 302)
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(data) {
if (xhr.readyState == 4) {
if (xhr.status == 301 || xhr.status == 302) {
// Get new location url don't GET it
}
}
};
xhr.open('HEAD', url, true);
xhr.send();
http://www.w3.org/TR/XMLHttpRequest/#infrastructure-for-the-send-method似乎指定请求应该遵循,是否有办法阻止它?
[XMLHttpRequest的的防止重定向]的可能的复制(HTTP://计算器.com/questions/228225/prevent-redirection-of-xmlhttprequest) – user 2016-02-15 17:07:36