I am doing a project according to the video course, but the information in the registration form cannot be submitted using a.jax. Please give me an answer.
P粉170622230
P粉170622230 2022-11-19 05:23:21
0
2
1059

$(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');

}

}

P粉170622230
P粉170622230

reply all(1)
Sanys

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template