Javascript AMP-转发页

Javascript AMP-转发页,javascript,amp-html,Javascript,Amp Html,我有一个AMP网站,那里有一个注册表格。 在后端有验证,如果验证失败,浏览器应该转发到新的url xhr.onreadystatechange = function () { if (xhr.readyState === 4 && xhr.status === 200) { quoteSent(); }else if (xhr.readyState === 4 && xhr.status === 30

我有一个AMP网站,那里有一个注册表格。 在后端有验证,如果验证失败,浏览器应该转发到新的url

    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
            quoteSent();
        }else if (xhr.readyState === 4 && xhr.status === 307){
            let url = xhr.responseText;
            console.log("url: " + url); //<-- prints properly to log
            setTimeout(function(){document.location.href = url;},1); //<-- Uncaught TypeError:
        }else{
            quoteNotSent();
        }
    };
url: https://example.com/quote/c1
log.js:264 [amp-script] Uncaught TypeError: Cannot set property 'href' of undefined
    at (amp-script%5Bscript=%22quoteFormScript%22%5D.js:64)