laravel: How to retrieve POST data through ajax in controller

controller, jquery, laravel

Solution

As you are using POST method you should pass a key/value pair instead of a string, an object, change:

data: $('.app_date').val(),

to:

data: { _date: $('.app_date').val() },

Problem

I'm trying to retrieve `$_POST` data submitted through jquery ajax func but there seem to be nothing passed. Here is my code: first my form: ``` {{ Form::open('', 'POST', array('id'=>'ajax')) }} {{ Form::text('_date', '', array('id'=>'datepicker', 'class'=>'app_date')) }} {{ Form::submit('Go', array('id'=>'go')) }} {{ Form::close() }} ``` And jquery: ``` $('#ajax').submit(function(e){ $.ajax({ url: 'appajax', type: 'POST', data: $('.app_date').val(), dataType: 'json', success: function(info){ console.log(info); } }); e.preventDefault(); }); ``` ... and finally in the controller: ``` public function post_appajax() { return Response::json(Input::get('_date')); } ``` And in console the output is `NULL`. What I'm I missing? I'm using laravel 3 currently downloadable from laravel.com. Thank you.

Original source