//regiser
<!-头部->{include file="public:header"/}<!-导航->{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"> Status:</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">手机:</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">确认密码:</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"/}
//Benutzer
<?php/ *** Registrierungsseite*/namespace appindexcontroller;use appcommoncontrollerBase;use appcommonmodelUser as UserModel;use thinkfacadeRequest;class User erweitert Base{ public function register() { $this ->assign('title','用户注册'); return $this ->fetch(); } öffentliche Funktion insert() { if ( Request ::isAjax()){ $data = Request::exclusive('password_confirm','post'); if(UserModel::create($data)) { return ['status'=> 1, 'message'=> '注册成功']; }else{ return ['status'=> 0, 'message'=> '注册失败']; } }else{ $this -> error("Erinnerungsfehler",'register'); } }}
你这个代码太乱了,也没有你下载的tp版本。你可以把整个项目,打包发给我。
现在thinkphp的版本,已经是6了。 可以学习6的版本。
按照你的问题,php没有操作完,报错了,js代码,就肯定不会有弹框。
你先看下php代码,是否有报错。 浏览器的F12,可以查看。