是否可以发送 xhr HTTP HEAD 请求以仅获取第一个请求的标头响应,而不像重定向一样自动跟随 301、302?我只对获取 url 的新位置感兴趣。例子:
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似乎指定应遵循请求,有没有办法阻止这种情况?