Laravel 5.4 ajax请求返回空数组

时间:2017-07-20 02:16:12

标签: php jquery ajax laravel-5

我试图ajax提交表单。这是代码:

var data = new FormData();
data.append("test","testvar");
var opt = {
    url:"{{route(email-process.store)}}",
    type:'POST',
    headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
    data:data,
    async:true,
    processData: false,
    success:function(result){
      console.log(result);
    }
  };
  if(data.fake) {
          // Make sure no text encoding stuff is done by xhr
          opt.xhr = function() { var xhr = jQuery.ajaxSettings.xhr(); xhr.send = xhr.sendAsBinary; return xhr; }
          opt.contentType = "multipart/form-data; boundary="+data.boundary;
          opt.data = data.toString();
      }
$.ajax(opt);

控制器部分:

public function store(Request $request)
{
    dd($request->all());
}
网络标签

returns []

0 个答案:

没有答案