title: jQuery Ajax POST request being sent as GET with Laravel
body: <p>I'm having a little trouble with Ajax. My project is in <code>Laravel 5</code> and it's running on <code>Apache</code> and <code>rewrite</code> is enabled and the <code>VerifyCsrfToken</code> middleware is in place. I'm trying to send a POST request to another route inside my project. Here's what my Ajax looks like:</p>
  <pre><code>$.ajax({
      url: '/add-device/',
      type: 'POST',
      data: form_data,
      success: function(data)
      {
          console.log(data);
      },
          error: function(data)
      {
          console.log(data);
      }
  });
  </code></pre>
  <p>When I click the button that triggers this Ajax, I get a <code>405: MethodNotAllowed</code> response. So I went into <code>routes.php</code> and I added a GET route. I've also included my POST route:</p>
  <pre><code>Route::get('add-device', function()
  {
      return 'hello';
  });
  
  Route::post('add-device', [
      'middleware' =&gt; 'auth',
      'uses' =&gt; 'FormController@add_device'
  ]);
  </code></pre>
  <p>I get the 'hello' message, so this is being sent as GET instead of POST. I tried to use <code>$.post</code> instead of <code>$.ajax</code> to force the POST but I still get the same behavior. For good measure, here is my <code>.htaccess</code> file:</p>
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  &lt;IfModule mod_negotiation.c&gt;
      Options -MultiViews
  &lt;/IfModule&gt;
  
      RewriteEngine On
  
      # Redirect Trailing Slashes...
      RewriteRule ^(.*)/$ /$1 [L,R=301]
  
      # Handle Front Controller...
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^ index.php [L]
  &lt;/IfModule&gt;
  </code></pre>
  <p>I also tried the Ajax without the trailing slash because of the rewrite rule (<code>/add-device</code>) but I get the same 'hello' message.</p>
  <p>I tested all of my Ajax requests (half GET, half POST) during development and they worked fine while being served with <code>artisan</code>. I've only had this problem come up after switching to <code>Apache</code>. I've moved into the QA phase of my project and so I moved the project onto our development server, which is running <code>Apache 2.4.10</code> on <code>Debian 8</code>.</p>
  <p>Anyone have any ideas on what is going on and how to resolve it?</p>
  <hr />
  <h3>Additional Content</h3>
  <pre><code>Exception trace:
   () at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:901
   Illuminate\Foundation\Application-&gt;abort() at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:21
   abort() at /home/debian/public_html/ZipPrinter/app/Handlers/Events/AbortTheRequest.php:28
   App\Handlers\Events\AbortTheRequest-&gt;handle() at n/a:n/a
   call_user_func_array() at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:327
   Illuminate\Events\Dispatcher-&gt;Illuminate\Events\{closure}() at n/a:n/a
   call_user_func_array() at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:218
   Illuminate\Events\Dispatcher-&gt;fire() at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:650
   event() at /home/debian/public_html/ZipPrinter/app/Services/ZipHelper.php:56
   App\Services\ZipHelper-&gt;__construct() at /home/debian/public_html/ZipPrinter/app/Services/DashHelper.php:43
   App\Services\DashHelper-&gt;__construct() at /home/debian/public_html/ZipPrinter/app/Http/Controllers/DashController.php:28
   App\Http\Controllers\DashController-&gt;__construct() at n/a:n/a
   ReflectionClass-&gt;newInstanceArgs() at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Container/Container.php:817
   Illuminate\Container\Container-&gt;build() at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Container/Container.php:656
   Illuminate\Container\Container-&gt;make() at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:644
   Illuminate\Foundation\Application-&gt;make() at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:161
   Illuminate\Foundation\Console\RouteListCommand-&gt;getControllerMiddleware() at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:142
   Illuminate\Foundation\Console\RouteListCommand-&gt;getMiddleware() at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:109
   Illuminate\Foundation\Console\RouteListCommand-&gt;getRouteInformation() at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:89
   Illuminate\Foundation\Console\RouteListCommand-&gt;getRoutes() at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php:75
   Illuminate\Foundation\Console\RouteListCommand-&gt;fire() at n/a:n/a
   call_user_func_array() at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Container/Container.php:523
   Illuminate\Container\Container-&gt;call() at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Console/Command.php:115
   Illuminate\Console\Command-&gt;execute() at /home/debian/public_html/ZipPrinter/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
   Symfony\Component\Console\Command\Command-&gt;run() at /home/debian/public_html/ZipPrinter/vendor/laravel/framework/src/Illuminate/Console/Command.php:101
   Illuminate\Console\Command-&gt;run() at /home/debian/public_html/ZipPrinter/vendor/symfony/console/Symfony/Component/Console/Application.php:874
  </code></pre>