What is returned is not in json format
乌鸦
乌鸦 2017-12-22 20:19:16
0
2
1694

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

乌鸦
乌鸦

reply all(2)
乌鸦

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

iamyl

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

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