Javascript Chrome提供在注册表上保存密码-Ajax

Javascript Chrome提供在注册表上保存密码-Ajax,javascript,php,ajax,forms,validation,Javascript,Php,Ajax,Forms,Validation,我有一个注册表单,当所有内容都签出并单击表单的注册按钮submit按钮时,它将运行以下所有代码。我的PHP控制器中的/xhrCreateUser方法进一步验证、清理POST数据,并将其插入数据库。对于目前的简单错误检查,如果/xhrCreateUser方法的回显为true,则会提醒用户帐户已创建,并重定向页面。但是,当调用重定向方法时,浏览器会在重定向用户时提供保存密码的功能。我希望这种行为发生在登录表单上,而不是注册表单上。如果没有调用重定向,则不会触发保存密码的提议,因此很明显,这是触发ch

我有一个注册表单,当所有内容都签出并单击表单的注册按钮submit按钮时,它将运行以下所有代码。我的PHP控制器中的/xhrCreateUser方法进一步验证、清理POST数据,并将其插入数据库。对于目前的简单错误检查,如果/xhrCreateUser方法的回显为true,则会提醒用户帐户已创建,并重定向页面。但是,当调用重定向方法时,浏览器会在重定向用户时提供保存密码的功能。我希望这种行为发生在登录表单上,而不是注册表单上。如果没有调用重定向,则不会触发保存密码的提议,因此很明显,这是触发chrome提供保存密码的提议。我不明白为什么会发生这种情况,它并没有在Firefox中采用这种行为。这是否与我发布密码输入元素的值或其他内容有关

我想chrome这样做是为了支持ajax登录表单,但它也在我的注册表单上这样做,这并不理想

register.addEventListener('click', function(e){
    if(validateName(0)){

        if(validateName(1)){

            if(validateUsername(2)){

                if(validateEmail(3)){

                    if(validatePassword(4)){

                        //Start XML HTTP Account Insertion
                        var xmlhttp;

                        if(window.XMLHttpRequest){
                            xmlhttp = new XMLHttpRequest();
                        } else {
                            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                        }

                        xmlhttp.onreadystatechange = function register(){
                            if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
                                var result = xmlhttp.responseText;
                                console.log(result);
                                if(result.indexOf('true') > -1){
                                    alert("Account has been created, you will be redirected");
                                    redirect();
                                    //redirect
                                } else {
                                    alert("Something went wrong, that's all we know. Please refresh the page and try again.");
                                }
                            }
                        }

                        xmlhttp.open("POST", "user/xhrCreateUser", true);
                        xmlhttp.setRequestHeader("Content-type","application/json");
                        xmlhttp.send(JSON.stringify({firstname:firstname.value, lastname:lastname.value, username:username.value, email:email.value, password:password.value}));

                    } else {
                        //password is bad
                        //toggle error classes for CSS here
                        forceError(4);
                        password.focus();
                    }

                } else {
                    //email is bad
                    //toggle error classes for CSS here
                    forceError(3);
                    email.focus();


                }
            } else {
                //username is bad
                //toggle error classes for CSS here
                forceError(2);
                username.focus();

            }

        } else {
            //lastname is bad
            //toggle error classes for CSS here
            forceError(1);
            lastname.focus();

        }
    } else {
        //firstname is bad
        //toggle error classes for CSS here
        forceError(0);
        firstname.focus();
    }
});
解决了的
通过将xmlhttp.open行中的true更改为false,使POST同步而非异步有效。您可以使用setTimeoutredirect;,欺骗chrome;,10打破提交和导航之间的联系,这听起来像是触发offerI希望解决它的原因,但它没有