Forms 关于Ajax POST成功的Jquery通知

Forms 关于Ajax POST成功的Jquery通知,forms,jquery,post,notifications,Forms,Jquery,Post,Notifications,在用户通过AJAX提交注册HTML表单后,我创建了一些jQuery通知,这些通知是根据从PHP文件返回的信息触发的。错误通知起作用,但不适用于成功发布到数据库。我知道应该显示成功通知,因为数据经过验证并写入数据库,并且AJAX post是成功的。但是,成功通知不起作用。这种技术性的原因是什么 我有以下设置: signup.html(页面*中包含以下ajax): new_user.php require("register-classes.php"); $register=new Regis

在用户通过AJAX提交注册HTML表单后,我创建了一些jQuery通知,这些通知是根据从PHP文件返回的信息触发的。错误通知起作用,但不适用于成功发布到数据库。我知道应该显示成功通知,因为数据经过验证并写入数据库,并且AJAX post是成功的。但是,成功通知不起作用。这种技术性的原因是什么

我有以下设置:

signup.html(页面*中包含以下ajax):

new_user.php

 require("register-classes.php");

 $register=new Register($_POST['fname'], $_POST['lname'], $_POST['email'], $_POST['sex'], $_POST['birthdate'], $_POST['phone'], $_POST['country'], $_POST['alias'], $_POST['handle'], $_POST["password"], $_POST["cpassword"], $_POST['network']);

if($register->checkFields()== false){

     echo -1;

 } else if($register->confirmPasswords()== false){

     echo -2;
 }else if($register->registerUser()!=false){


     echo -4;
 } else if($register->registerUser()==false){
     echo -3;
 }


and register-classes.php (which contains classes for processing sign up form)

    class Register {

        public function __construct($fname, $lname, $mail, $sex,
        $birthday, $phonenumber, $regCountry, $alias, $username,
        $password, $conf_password, $network_site) {

            //Copy Constructor
            $this->site=$network_site;
            $this->firstname=$fname;
            $this->lastname=$lname;
            $this->email=$mail;
            $this->sex=$sex;
            $this->birthdate=$birthday;
            $this->phone=$phonenumber;
            $this->country=$regCountry;
            $this->displayname=$alias;
            $this->handle=$username;
            $this->salt="a2cflux9e8g7ds6ggty589498j8jko007876j89j8j7";
            $this->password=crypt($this->salt.$password);
            $this->joindate=date("Y-m-d H:i:s");
            $this->confirm_password1=$password;
            $this->confirm_password2=$conf_password;

        }

        public function registerUser(){

            $database=new Database();
            $database->getConnection();
            $database->startConnection();

            //Check database to insure user and email address is not already in the system.                     
            $checkUsers= mysql_query("SELECT network_users.network_id
            FROM network_users, network_profile
            WHERE network_users.handle = '$this->handle'
            OR network_profile.email = '$this->email'");

            $numRecords= mysql_num_rows($checkUsers);

            if($numRecords == 0){

                $addUser= mysql_query("INSERT INTO network_users(handle, password, date_created, parent_network, site_created, active, account_type, del)
                values('$this->handle', '$this->password', '$this->joindate',' fenetwork', 'network', 'active', 'standard', 'F')") or die(mysql_error());

                $networkId=mysql_insert_id();

                $addProfile= mysql_query("INSERT INTO network_profile(network_id, first_name, last_name, email, sex, birthdate, phone, country, display_name, del)
                values('$networkId', '$this->firstname', '$this->lastname', '$this->email','$this->sex', '$this->birthdate', '$this->phone', '$this->country', '$this->displayname', 'F')") or die(mysql_error());

                $this->addUser;
                $this->addProfile;

                            return true;

            }
            else{

                return false;
            }
        }

        public function checkFields(){
            if(($this->firstname)!="" && ($this->lastname)!="" && ($this->email)!="" && ($this->sex)!="" && 
                ($this->birthdate)!="" &&($this->country)!="" && ($this->handle)!="" && ($this->password)!=""){

                return true;     
            } else {

                return false;
            }

        }

        public function confirmPasswords(){

            if($this->confirm_password1==$this->confirm_password2){

                return true;
            } else {

                return false;
            }
        }

        private $site, $firstname, $lastname, $email,
        $sex, $birthdate, $phone, $country, $displayname, 
        $handle, $password, $salt, $joindate, $confirm_password1, $confirm_password2;

        protected $addUser, $addProfile;

    }

我发现了问题。问题是由于printf()函数是数据库类中少数类成员的一部分。它们导致函数在registerUser()中完成并返回布尔值true或false时中断


谢谢大家的帮助和帮助。我会放弃投票,但我没有足够的声望点数。哈哈

尝试添加
console.log(数据) require("register-classes.php");

 $register=new Register($_POST['fname'], $_POST['lname'], $_POST['email'], $_POST['sex'], $_POST['birthdate'], $_POST['phone'], $_POST['country'], $_POST['alias'], $_POST['handle'], $_POST["password"], $_POST["cpassword"], $_POST['network']);

if($register->checkFields()== false){

     echo -1;

 } else if($register->confirmPasswords()== false){

     echo -2;
 }else if($register->registerUser()!=false){


     echo -4;
 } else if($register->registerUser()==false){
     echo -3;
 }


and register-classes.php (which contains classes for processing sign up form)

    class Register {

        public function __construct($fname, $lname, $mail, $sex,
        $birthday, $phonenumber, $regCountry, $alias, $username,
        $password, $conf_password, $network_site) {

            //Copy Constructor
            $this->site=$network_site;
            $this->firstname=$fname;
            $this->lastname=$lname;
            $this->email=$mail;
            $this->sex=$sex;
            $this->birthdate=$birthday;
            $this->phone=$phonenumber;
            $this->country=$regCountry;
            $this->displayname=$alias;
            $this->handle=$username;
            $this->salt="a2cflux9e8g7ds6ggty589498j8jko007876j89j8j7";
            $this->password=crypt($this->salt.$password);
            $this->joindate=date("Y-m-d H:i:s");
            $this->confirm_password1=$password;
            $this->confirm_password2=$conf_password;

        }

        public function registerUser(){

            $database=new Database();
            $database->getConnection();
            $database->startConnection();

            //Check database to insure user and email address is not already in the system.                     
            $checkUsers= mysql_query("SELECT network_users.network_id
            FROM network_users, network_profile
            WHERE network_users.handle = '$this->handle'
            OR network_profile.email = '$this->email'");

            $numRecords= mysql_num_rows($checkUsers);

            if($numRecords == 0){

                $addUser= mysql_query("INSERT INTO network_users(handle, password, date_created, parent_network, site_created, active, account_type, del)
                values('$this->handle', '$this->password', '$this->joindate',' fenetwork', 'network', 'active', 'standard', 'F')") or die(mysql_error());

                $networkId=mysql_insert_id();

                $addProfile= mysql_query("INSERT INTO network_profile(network_id, first_name, last_name, email, sex, birthdate, phone, country, display_name, del)
                values('$networkId', '$this->firstname', '$this->lastname', '$this->email','$this->sex', '$this->birthdate', '$this->phone', '$this->country', '$this->displayname', 'F')") or die(mysql_error());

                $this->addUser;
                $this->addProfile;

                            return true;

            }
            else{

                return false;
            }
        }

        public function checkFields(){
            if(($this->firstname)!="" && ($this->lastname)!="" && ($this->email)!="" && ($this->sex)!="" && 
                ($this->birthdate)!="" &&($this->country)!="" && ($this->handle)!="" && ($this->password)!=""){

                return true;     
            } else {

                return false;
            }

        }

        public function confirmPasswords(){

            if($this->confirm_password1==$this->confirm_password2){

                return true;
            } else {

                return false;
            }
        }

        private $site, $firstname, $lastname, $email,
        $sex, $birthdate, $phone, $country, $displayname, 
        $handle, $password, $salt, $joindate, $confirm_password1, $confirm_password2;

        protected $addUser, $addProfile;

    }