laravel后台返回ajax数据
Posted 万里冰封
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了laravel后台返回ajax数据相关的知识,希望对你有一定的参考价值。
后台模式:
1 $array = array(‘msg‘=>‘添加失败!‘,‘status‘=>‘false‘); 2 return json_encode($array);
前台显示:
1 $.ajax({ 2 url: "{{url(‘ucenter/saveTrain‘)}}", 3 type: "post", 4 dataType: "json", 5 data: {"content": content,"read": read,"trainer":trainer,"time1":time1,"where":where,"result":result,"score":score,‘_token‘: "{{csrf_token()}}"}, 6 success: function (result) { 7 8 if(result.status == ‘true‘){ 9 layer.msg(result.msg); 10 location.href = ‘{{url(‘ucenter/train‘)}}‘; 11 }else{ 12 layer.msg(result.msg); 13 return false; 14 } 15 },
以上是关于laravel后台返回ajax数据的主要内容,如果未能解决你的问题,请参考以下文章