//regiser
<!-頭部->{include file="public:header"/}<!-導(dǎo)航->{include file="public:nav"/}<div class="col-md-8">? ? <div class="page-header text-center">? ? ? ? <h2>用戶注冊</h2>? ? </div>? ? <form class="form-horizontal" method='post' id="login">? ? <div class="form-group">? ? ? ? ? ? <label for="inputEmail1" class="col-sm-2 control-label">用戶:</label>? ? ? ? ? ? <div class="col-sm-10">? ? ? ? ? ? ? ? <input type="text" name="name" class="form-control" id="inputEmail1" placeholder="username">? ? ? ? ? ? </div>? ? ? ? </div>? ? ? ? <div class="form-group">? ? ? ? ? ? <label for="inputEmail2" class="col-sm-2 control-label">郵箱:</label>? ? ? ? ? ? <div class="col-sm-10">? ? ? ? ? ? ? ? <input type="text" name="email" class="form-control" id="inputEmail2" placeholder="Email">? ? ? ? ? ? </div>? ? ? ? </div>? ? ? ? <div class="form-group">? ? ? ? ? ? <label for="inputEmail3" class="col-sm-2 control-label">手機(jī):</label>? ? ? ? ? ? <div class="col-sm-10">? ? ? ? ? ? ? ? <input type="text" name="mobile" class="form-control" id="inputEmail3" placeholder="Mobile">? ? ? ? ? ? </div>? ? ? ? </div>? ? ? ? <div class="form-group">? ? ? ? ? ? <label for="inputEmail4" class="col-sm-2 control-label">密碼:</label>? ? ? ? ? ? <div class="col-sm-10">? ? ? ? ? ? ? ? <input type="password" name="password" class="form-control" id="inputEmail4" placeholder="Password">? ? ? ? ? ? </div>? ? ? ? </div>? ? ? ? <div class="form-group">? ? ? ? ? ? <label for="inputEmail5" class="col-sm-2 control-label">確認(rèn)密碼:</label>? ? ? ? ? ? <div class="col-sm-10">? ? ? ? ? ? ? ? <input type="password"? ?name="password_confirm"? class="form-control" id="inputEmail5" placeholder="Password_confirm">? ? ? ? ? ? </div>? ? ? ? </div>? ? ? ? <div class="form-group">? ? ? ? ? ? <div class="col-sm-offset-2 col-sm-10">? ? ? ? ? ? ? ? <button type="submit" class="btn btn-default" id="register">注冊</button>? ? ? ? ? ? </div>? ? ? ? </div>? ? </form></div><script>? ? $(function () {? ? ? ? $("#register").on('click',function () {? ? ? ? ? ?alert($('#login').serialize());? ? ? ? ? ? $.ajax({? ? ? ? ? ? ? ? type:'post',? ? ? ? ? ? ? ? url:"{:url('index/user/insert')}",? ? ? ? ? ? ? ? data:$('#login').serialize(),? ? ? ? ? ? ? ? dataType:'json',? ? ? ? ? ? ? ? success:function (data) {? ? ? ? ? ? ? ? ? ?alert('成功了')? ? ? ? ? ? ? ? }? ? ? ? ? ? })? ? ? ? })? ? })</script>{include file="public:rigt"/}{include file="public:footer"/}
//User
<?php/** * registration page */namespace app\index\controller;use app\common\controller\Base;use app\common\model\User as UserModel;use think\facade\Request;class User extends Base{? ? public function register()? ? {? ? ? ? $this ->assign('title','用戶注冊');? ? ? ? return $this ->fetch();? ? }? ? public function insert()? ? {? ? ? ? if ( Request ::isAjax()){? ? ? ? ? $data =? Request::except('password_confirm','post');? ? ? ? ? ?if(UserModel::create($data)) {? ? ? ? ? ? ? ?return ['status'=> 1, 'message'=> '注冊成功'];? ? ? ? ? ? }else{? ? ? ? ? ? ? ?return ['status'=> 0, 'message'=> '注冊失敗'];? ? ? ? ? ?}? ? ? ? }else{? ? ? ? ? $this -> error("請求類型錯(cuò)誤",'register');? ? ? ? }? ? }}
Your code is too messy, and there is no TP version you downloaded. You can package the entire project and send it to me.
The current version of thinkphp is already 6. You can learn version 6.
According to your question, if the PHP operation is not completed and an error is reported, there will definitely be no pop-up box in the JS code.
Check the php code first to see if there are any errors. F12 of the browser can be viewed.