title: POST 405 (Method not allowed) when trying to post AJAX request - Laravel 4
body: <p>I am trying to issue a simple AJAX request to populate a menu in Laravel, however, I am having a lot of trouble with getting it to work properly.</p>
  
  <p>I am not sure what the issue is, and after a couple hours of searching, I cannot find anything that can help.</p>
  
  <p>Here is my AJAX request:</p>
  
  <pre><code>$.ajax({
              type: 'POST',
              url: '/ajax/populateApiAuth',
              data: json,
              dataType: 'JSON',
              success: function (json) {
                  alert('test');
                  return true;
              },
              error: alert('fail')
  });
  </code></pre>
  
  <p>My route to the AJAX callback:</p>
  
  <pre><code>Route::get('/ajax/populateApiAuth', 'ApiController@populateApiAuth');
  </code></pre>
  
  <p>and my controller to handle the AJAX callback in ApiController:</p>
  
  <pre><code>public function populateApiAuth()
      {
          return Response::json(array('msg' =&gt; 'test');
      }
  </code></pre>
  
  <p>When sending the AJAX request, it returns with the fail message in the error parameters, and in the console, it tells me:</p>
  
  <pre><code>POST http://localhost:8000/ajax/populateApiAuth 405 (Method Not Allowed) 
  </code></pre>
  
  <p>Researching this error message, it results from making a POST request to a different domain/server? How can this be?</p>
  
  <p>I have tried to use an absolute URL for the AJAX request with:</p>
  
  <pre><code>url: '{{ URL::to("ajax/populateApiAuth") }}
  </code></pre>
  
  <p>which gives the full URL: <code>http://localhost:8000/ajax/populateApiAuth</code> but that does not solve the issue either.</p>