Home  >  Q&A  >  body text

No response after clicking the login button

The code of checkLogin is copied, it should be correct, but I don’t know what went wrong, and there is no response when I click the submit button

public function checkLogin(Request $request)

{

//Initial return parameters

$status =0;

$result ='';

$data = $request -> param();

//Create validation rules

$rule=[

'name|Username'=>'require', //Username is required

'password|password'=>'require', //Password is required

'verify|Verification code'=>'require|captcha', //Username is required

];

//Customized verification failure prompt message

$msg=[

'name'=>['require'=>'User The name cannot be empty, please check'],

'password'=>['require'=>'The password cannot be empty, please check'],

'verify'= & gt; [

'request' = & gt; '' verification code cannot be empty, please check ',

##' captcha '= & gt; ],

];

//Verify

//$result will only return two values: true-> indicates that the verification is passed. If a string is returned, It is a user-defined error prompt

$result=$this->validate($data,$rule,$msg);


## //If the verification is passed, execute


if($result===true){

//Construct query conditions

$map =[

                                                                                                                                                                                                                                                                                                 ];

## //Query user information

$user=UserModel::get($map);

if($user == null){

              $result = 'The user was not found';               }else{

                      $result =                         $result =  'Verification passed, click [OK] to enter';

}

## }

return ['status'=>$status ,'message'=>$result,'data'=>$data];

}

<div class="formControls col-xs-8 col-xs-offset-3">

<input name="" type="button" id="login" class= "btn btn-success radius size-L" value=" Login    Record ">

</div>

<! -- Ajax submission script-->

<script>

$(function(){

//Add a click event to the login button

$("#login").on('click',function(event){

$.ajax({

type:"POST".//The submission method is post

url:"{:url('checkLogin')}",//Set the address of the script file for submitting data processing

data:$("form").serialize(),/ /Serialize the data of the current form and submit it

dataType:'json',//Set the type of submitted data to json

success: function(data){ //Only the flag bit is 1 before processing

if(data.status==1){

alert(data.message);

window.location.href="{:url ('index/index')}";

}else{

alert(data.message);

}

}

});

})

})

</script>


##

鹏(•̀ω•́)y鹏(•̀ω•́)y2466 days ago1706

reply all(1)I'll reply

  • 鹏(•̀ω•́)y

    鹏(•̀ω•́)y2017-12-23 13:12:04

    Solved, the punctuation was wrong and it was written as.

    reply
    0
  • Cancelreply