首页 > 代码库 > laravel后台返回ajax数据
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 = http://www.mamicode.com/‘{{url(‘ucenter/train‘)}}‘;"color: #008080">11 }else{ 12 layer.msg(result.msg); 13 return false; 14 } 15 },
laravel后台返回ajax数据
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。