Laravel won't submit ajax

Discussion in 'PHP' started by makamo66, Dec 31, 2013.

  1. #1
    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'));
    Code (markup):
    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');
    }
    Code (markup):
    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); }
      });
    Code (markup):
     
    makamo66, Dec 31, 2013 IP
  2. felixjet

    felixjet Greenhorn

    Messages:
    56
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    20
    #2
    before filter shoulnt be "auth" instead of "suth"? :/
     
    felixjet, Jan 7, 2014 IP