public function checkLogin(Request $request)
{
//Initial return parameters
$status = 0;
$result = ' ';
$data = $request -> param();
return ['status'=>$status, 'message'= >$result, 'data'=>$data];
}
$(function(){
//Add a click to the login button Event
$(#login).on('click', function(event){
$.ajax({
type: "POST",
url: "{:url('checkLogin')}",
data: $("form").serialize(), //Serialize the current form data before submitting it
dataType: 'json',
success: function(data){ //Only if the return flag is 1, it will be processed
alert (data.status);
}
});
})
})
##
It doesn’t work when I click to log in here. Can you help me take a look?
Public Function Checklogin (Request $ Request)
{
## // Initialization Back parameters $ Status = 0;# $ result ='';
$data = $request->param();
return ['status'=>$status,'message'=>$result,' data'=>$data];
}
$(function(){
$("#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
data:$("form").serialize(),//Serialize the data submitted by the current script and then submit it
dataType:'json',//Set the type of submitted data to JSON
success:function(data){
alert(data);
}
});
})
})
Handsome guy, the semicolon there, I have the same problem
Already found it. I just accidentally missed a semicolon. Sorry to trouble everyone. . .