title: ajax request not working for laravel 5.0
body: <p>I am doing Google Oauth login using Google Api's in Laravel 5.0. I get the data of currently logged in user's email,id_token and now I want to send these data to the controller(SigninController) for calling our own api and get the response back to the front end (signin.blade.php) via an Ajax query . But My Ajax query is not working. I am attaching the codes here .</p>
  
  <p>My Signin.blade.php file's ajax looks like(I have included csrf header) :</p>
  
  <pre><code>    $.ajax({
              url: '/signin/oauth',
              type:"POST",
              data: data,
              headers: { 'X-CSRF-Token' : token},
              success:function(data){
  
                  console.log(data);
                  if(data){
                      console.log("Success nowwww for ajax expected data!");
                     // window.location.href = '{{url("/home")}}';
                  }
                  else{
                      console.log("Success ajax ! But not expected data!");
                     // window.location.href = '{{url("/signup")}}';
                  }
  
              },error:function(){
                  alert("error!! ajax failure !!!!");
              }
      });
  </code></pre>
  
  <p>My routes.php looks like :</p>
  
  <pre><code>    Route::post('/signin/oauth', [
         'uses' =&gt; 'SigninController@signinProcessOauth',
         'as' =&gt; 'post_signin_oauth',
      ]);
  </code></pre>
  
  <p>In my SigninController's signinProcessOauth function normal "Request for Form" is working but "Request->ajax()" maybe not working . It looks like : </p>
  
  <pre><code>     .
       .
       use Illuminate\Http\Request;
       use Illuminate\Support\Facades\Session;
       .
       .
       public function signinProcessOauth(Request $request)
       {
        $getData = $request-&gt;ajax();
  
        if ($getData) {
  
          $authCode = $request['authCode'];
          $idToken = $request['idToken'];
          $userEmail = $request['userEmail'];
  
                // call the api here and send the above data to the server  and process the response like saving the cookie etc
  
          return $authCode;   // return according to the response,this will return in ajax success function,right now it is authcode just for testing purpose
       }
  
       return "error";
      }
  </code></pre>
  
  <p>Everytime I run the code, I get "error!! ajax failure !!!!" response i.e. ajax's failure function is called . I can't figure it out Where the problem is? Or Is there any other way to to send the datam from view to controller and get back the response to the frontend ?</p>
  
  <p>Thank you for reading such long post patiently . :) :)</p>