前台:
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 data 5 //e.g return the request data follow this: 6 return json_encode($request); 7 }
参考:https://segmentfault.com/q/1010000008852823
时间: 2024-11-08 23:05:27