$(function(){
$("#register").on('click',function (){
alert($('#login').serialize ());
/ //Request address
// url: "{:url('index/user/insert')}",
// //Submit form data
// data: $('#login').serialize(),
// //Returned data type
// dataType: 'json',
// success:function(data){
// alert('successful');
// },
// error:function(data){
## }) </script>public function insert() { // Determine whether the request is an Ajax request if (Request::isAjax()){ //Use the model to create data //Get the data submitted by the user through the form Data (except confirm password) $data = Request::except('password_confirm','post'); //Add data and determine whether it is successful if (UserModel::create($data)){ return ['status'=>1,'message'=>'Congratulations, registration successful']; }else{ return ['status'=>0,'message'=>'Registration failed, please check all data carefully']; } }else { $this->error("Request type error",'register'); } }
Check the front-end console to see if the request information of your post is correct?
Or use dump on the backend to print the requested data