return ['status'=>$status,'message'=>$result, 'data'=>$data];
This is written based on the video, and it is written like this in the video.
Server-side code:
public function checkLogin(Request $request){ echo "Enter the login verification method"; //Initial return parameters $status = 0; $result = 'sdasdas'; $data = $request->param(); return ['status'=>$status,'message '=>$result, 'data'=>$data];}
jq's ajax code:
$.ajax({ type:"post ", url:"{:url('checkLogin')}", data:{user:username,pwd:password,sf:shenfen,xt:xitong}, dataType:"json" , success:function(res){ alert("Execution successful"+res); },error:function(){ alert("jadhasjdhajlsk") }})
The front end will finally display: jadhasjdhajlsk
The JSON format is text, and it is echoed out. Yours is a return, and it is an array. How can it be JSON? You need to use json_decode(array); to convert the array into text, so that the front end can get json
This is written based on the video, and it is written like this in the video.
Server-side code:
public function checkLogin(Request $request)
{
echo "Enter the login verification method";
//Initial return parameters
$status = 0;
$result = 'sdasdas';
$data = $request->param();
return ['status'=>$status,'message '=>$result, 'data'=>$data];
}
jq's ajax code:
$.ajax({
type:"post ",
url:"{:url('checkLogin')}",
data:{user:username,pwd:password,sf:shenfen,xt:xitong},
dataType:"json" ,
success:function(res){
alert("Execution successful"+res);
},error:function(){
alert("jadhasjdhajlsk")
}
})
The front end will finally display: jadhasjdhajlsk
The JSON format is text, and it is echoed out. Yours is a return, and it is an array. How can it be JSON? You need to use json_decode(array); to convert the array into text, so that the front end can get json