makamo66 Posted December 31, 2013 Share Posted December 31, 2013 I'm trying to get the user/dashboard page to submit as ajax. My console shows ABOUT TO SEND SUCCESS! Done. so that means the jquery post was sent but I keep getting "No ajax" on the user/dashboard page. How do I submit a page as ajax? added to routes.php Route::post('user/dashboard', array('before' => 'suth', 'uses' => 'UserController@calendar')); added to UsersController.php public function calendar(){ print_r($_POST); if (Request::ajax()) { return "yeahhhh"; } return "<br />No ajax"; return View::make('user.dashboard.index'); } added to main.js $.ajax({ url: 'http://beta.opentemp.local/user/dashboard', data: {} + "&_token=" + $("input[name=_token]").val(), type: 'POST', 'beforeSend': function(xhr, settings) { console.log('ABOUT TO SEND'); }, 'success': function(result, status_code, xhr) { console.log('SUCCESS!'); }, 'complete': function(xhr, text_status) { console.log('Done.'); }, 'error': function (XMLHttpRequest, textStatus, errorThrown) { alert("Error with ajax Function: "+ textStatus+" "+errorThrown); } }); Quote Link to comment https://forums.phpfreaks.com/topic/285009-laravel-wont-submit-ajax/ Share on other sites More sharing options...
trq Posted December 31, 2013 Share Posted December 31, 2013 What does the console show as returning from the request? Quote Link to comment https://forums.phpfreaks.com/topic/285009-laravel-wont-submit-ajax/#findComment-1463493 Share on other sites More sharing options...
sKunKbad Posted January 16, 2014 Share Posted January 16, 2014 I believe you need to echo your response, not return it. Also, your Ajax should probably declare a data type, and add result to the call to console.log. Quote Link to comment https://forums.phpfreaks.com/topic/285009-laravel-wont-submit-ajax/#findComment-1465364 Share on other sites More sharing options...
bastion Posted January 29, 2014 Share Posted January 29, 2014 You don't echo the response, you return it -- this is correct. The 'suth' filter could be stopping this route from executing, without seeing that everything else looks fine. Quote Link to comment https://forums.phpfreaks.com/topic/285009-laravel-wont-submit-ajax/#findComment-1466991 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.