Jump to content

Laravel won't submit ajax


makamo66

Recommended Posts

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); }
  });

 

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.