HEAD xhr之后重定向

时间:2019-03-07 18:31:25

标签: javascript ajax xmlhttprequest

如果特定的网址正在执行重定向,我想用javascript重新加载当前页面。我不需要知道重定向的网址.xhr请求正在执行,当我检查请求时我确实获得了302重定向,但是我的特定重定向没有发生。

var xhr = new XMLHttpRequest();
xhr.open('HEAD', 'https://www.filterbypass.me/s.php?k=BbrSU%2F%2F39m5gKhLDr31ZqjKYgrAdALscySz%2B6YarDYTH5G9hSDc%2B&b=4&f=norefer');
xhr.onreadystatechange = function() {
    if (xhr.readyState == 4) {
        if (xhr.status == 301 || xhr.status == 302) {
            //url expired , reload
            console.log('perform redirection');
            window.location.replace('https://www.google.com');
        }
    }
};
xhr.send();

我没有看到console.log,我已经尝试使用xhr.readyState == 2

0 个答案:

没有答案