title: Ajax Request not accessing Controller, Laravel
body: <p>I have a simple post request that is currently working if I dont specify a controller in my route file. When I change the route to access a controller I have specifically created for AJAX requests it returns a 500 Internal server error. </p>
  
  <p>My Route.php looks like this:</p>
  
  <pre><code>Route::post('ajaxTagStore', 'AjaxController@postAjaxTag');
  </code></pre>
  
  <p>My Controller looks like this:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  
  use App\Http\Requests;
  
  class AjaxController extends Controller
  {
  public function postAjaxTag(Request $request) {
    if(Request::ajax()){
      return Response::json(Request::all());
    }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and lastly my AJAX code looks like this:</p>
  
  <pre><code>$.ajaxSetup({
    headers: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
  });
  
  $(document).ready(function(){
    $('#tag-btn').click(function(){
      var fname = $('#firstname').val();
      var lname = $('#lastname').val();
      var token = $('#token').val();
  
      var dataString = $('#tag').serialize();
  
      $.ajax({
        type: 'POST',
        url: '/ajaxTagStore',
        data: dataString,
        success: function(response){ // What to do if we succeed
          console.log(response);
          $('#postRequestData').html(response);
        }
      })
  
    });
  });
  </code></pre>
  
  <p>As I said it works if I don't specify a controller and just use this:</p>
  
  <pre><code>Route::post('ajaxTagStore', function(){
   if(Request::ajax()){
    return Response::json(Request::all());
   }
  });
  </code></pre>
  
  <p>Any suggestions as to why this is? (I am using a csrf-token also)</p>