码迷,mamicode.com
首页 > Web开发 > 详细

laravel5.1接收ajax数据

时间:2017-09-14 13:23:41      阅读:304      评论:0      收藏:0      [点我收藏+]

标签:err   func   https   this   his   inpu   segment   logs   http   

前台:

 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

laravel5.1接收ajax数据

标签:err   func   https   this   his   inpu   segment   logs   http   

原文地址:http://www.cnblogs.com/gy1010/p/7519860.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!