/** * Laravel / jQuery AJAX code example * See conversation here: http://laravel.io/forum/04-29-2015-people-asking-about-jquery-ajax * * Drop this code into your App/Http/routes.php file, and go to /ajax/view in your browser * Be sure to bring up the JavaScript console by pressing F12. */ // This is your View AJAX route - load this in your browser Route::get('/ajax/view', function () { // really all this should be set up as a view, but I'm showing it here as // inline html just to be easy to drop into your routes file and test ?> 'some data'); // return a JSON response return Response::json($data); }); // this is your POST AJAX route Route::post('/ajax/post', function () { // pass back some data, along with the original data, just to prove it was received $data = array('value' => 'some data', 'input' => Request::input()); // return a JSON response return Response::json($data); });