前台:
1 ????$.ajax({ 2 ????????type: ‘POST‘, 3 ????????url: ‘{!! url(‘aw/data‘) !!}‘, 4 ????????data:{‘_token‘:‘<?php echo csrf_token() ?>‘,‘option‘:1}, 5 ????????dataType: ‘json‘, 6 ????????success: function (data) { 7 ????????????alert(data); 8 ????????}, 9 ????????error: function () {10 ????????????alert("error")11 ????????}12 ????});
后台:
1 public function postData()2 {3 ????$request = Input::all();4 ????//todo something and return json data5 ????//e.g return the request data follow this:6 ????return json_encode($request);7 }
参考:https://segmentfault.com/q/1010000008852823
laravel5.1接收ajax数据
原文地址:http://www.cnblogs.com/gy1010/p/7519860.html