title: Laravel ajax POST method not allowed
body: <p>I try to store comments about clients in admin panel.<br>
  I get error 405 (Method not allowed) when sending ajax request in Laravel 5.5<br>
  And everything works fine when I send data using html form without ajax.</p>
  
  <p><strong>Ajax:</strong>  </p>
  
  <pre><code>$.ajaxSetup({
      headers: {
          "X-CSRF-TOKEN": $("meta[name='csrf-token']").attr("content")
         }
      });
  
  $(".save-comment").click(function(e) {
      e.preventDefault();
      var id = $("#hidden-id").val();
      var type = $("#slect-comment-type option:selected").val();
      var text = $("#comment").val();
      console.log(id);
      console.log(type);
      console.log(text);
  $.post("storeComment", { id: id, type: type, text: text })
      .done(function(data) {
      console.log(data);
      alert("Success");
      $("#add-comment").css("display", "none");
      })
      .fail(function() {
      alert("Fail");
      });
  });
  </code></pre>
  
  <p>I pass correct data in { id: id, type: type, text: text } as I see in Console.</p>
  
  <p><strong>Route:</strong></p>
  
  <pre><code>Route::post('/comments/store' , 'CommentController@store')-&gt;name('storeComment');
  </code></pre>
  
  <p><strong>CommentController:</strong></p>
  
  <pre><code>public function store(Request $request) {
      $id = $request-&gt;input('id');
      $type = $request-&gt;input('type');
      $text = $request-&gt;input('text');
  
      $comment = new Comment();
      $comment-&gt;client_id = $id;
      $comment-&gt;type = $type;
      $comment-&gt;text = $text;
      $comment-&gt;created_by = $request-&gt;user()-&gt;first_name.' '.$request-&gt;user()-&gt;last_name;
      $comment-&gt;save();
  return response()-&gt;json(['success'=&gt;'Success']);
  }
  </code></pre>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;form class="form-horizontal" method="POST" action="{{route ('storeComment')}}"&gt;
      {{ csrf_field() }}
      &lt;input id="hidden-id" type="hidden" name="id" value="{{$id}}"&gt;
      &lt;div class="form-group"&gt;
          &lt;label class="col-md-4 control-label" for="commentSelect"&gt;Comment type&lt;/label&gt;
      &lt;div class="col-md-6"&gt;
          &lt;select id="slect-comment-type" name="type" class="form-control"&gt;
              &lt;option value="Call"&gt;Call&lt;/option&gt;
              &lt;option value="Mail"&gt;Mail&lt;/option&gt;
          &lt;/select&gt;
      &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group{{ $errors-&gt;has('comment') ? ' has-error' : '' }}"&gt;
          &lt;label for="comment" class="col-md-4 control-label"&gt;Comment&lt;/label&gt;
      &lt;div class="col-md-6"&gt;
          &lt;textarea name="text" class="form-control" rows="5" id="comment"&gt;&lt;/textarea&gt;
          @if ($errors-&gt;has('comment'))
          &lt;span class="help-block"&gt;
          &lt;strong&gt;{{ $errors-&gt;first('comment') }}&lt;/strong&gt;
          &lt;/span&gt;
          @endif
      &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
      &lt;div class="col-md-6 col-md-offset-4"&gt;
          &lt;button type="submit" class="btn btn-primary btn-sm save-comment"&gt;Save&lt;/button&gt;
      &lt;/div&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/vhCHC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vhCHC.png" alt="enter image description here"></a></p>