繁体   English   中英

php成功响应后,如何将用户重定向到ajax中的另一个页面

[英]how can i redirect users to another page in ajax after success response from php

我有一个很好的javascript函数。 它将所有错误消息从php文件返回到ID resto的范围非常好。 我需要,如果php文件返回一个特定的Massege(您已成功地放弃了!请检查您的电子邮件以激活您的帐户),则用户应被重定向到另一页。 有人可以帮忙吗

        function divsub(){
    var firstname= document.getElementById('first_name').value;
    var lastname= document.getElementById('lastname').value;
    var username= document.getElementById('username').value;
    var email= document.getElementById('email').value;
    var emailconfirm= document.getElementById('confirmemail').value;
    var pass= document.getElementById('pass_id').value;
    var passconfrim= document.getElementById('confirmpassword').value;
    var phone= document.getElementById('phone').value;
    var datastring = 'first_name='+firstname+'&lastname='+lastname+'&username='+username+'&email='+email+'&confirmemail='+emailconfirm+'&pass_id='+pass+'&confirmpassword='+passconfrim+'&phone='+phone;
    $.ajax({

        type:"POST",
        url:"regestration.php",
        data:datastring,
        cache:false,
        success:function(html){
                if(html === "you have sucessfuly regestered!check your email to activated your account.") {

                    var ffirstname= document.getElementById('first_name').value;
                    var eemail= document.getElementById('email').value;

                  location.href = "rregsuccess.php?first_name="+ffirstname+"&email"+eemail;


                }
                else{
                    $('#resto').html(html);
        //  window.location.href = "regsuccess.php";
                }

        }

    });
    return false;
}
// after ajax success
// Redirect user to url
window.open("https://google.com","_self");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM