title: MethodNotAllowedHttpException in Laravel 5
body: <p><b>Routes.php</b></p>
  
  <pre><code>Route::post('deactivatecountry', array(
              'as'   =&gt; 'deactivatecountry', 
              'uses' =&gt; 'CountriesController@deactivateCountry'
  ));
  Route::post('deactivatestate', array(
              'as'   =&gt; 'deactivatestate', 
              'uses' =&gt; 'StatesController@deactivateState'
  ));
  </code></pre>
  
  <p><b>Javascript</b></p>
  
  <pre><code>function deactivateCountry(country_id) {
      if (window.XMLHttpRequest) {
          xmlhttp = new XMLHttpRequest();
      } else {
          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {}
      }
      xmlhttp.open("POST","deactivatecountry", true);
      xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlhttp.send("country_id=" + country_id);
  }
  
  function deactivateState(state_id) {
      if (window.XMLHttpRequest) {
          xmlhttp = new XMLHttpRequest();
      } else {
          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {}
      }
  
      xmlhttp.open("POST","deactivatestate", true);
      xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlhttp.send("state_id=" + state_id);
  }
  </code></pre>
  
  <p>When the deactivateCountry function in my javascript is called, the code works perfectly fine. It calls the deactivateCountry method in the CountriesController and it deactivates the country as expected. </p>
  
  <p>But when I call the deactivateState function, it throws a MethodNotAllowedHttpException and I have no idea why. </p>
  
  <p>Both the country and the state have the same route and the functions are similar but one is working and the other is not. </p>
  
  <p>Can somebody please help me with this? I have been sitting on this for a couple of hours now and I'm not able to figure out why this is happening</p>
  
  <p><b>Here is the error that I am getting when I call the deactiveState method</b></p>
  
  <pre><code>1/1
  MethodNotAllowedHttpException in RouteCollection.php line 207:
  in RouteCollection.php line 207
  at RouteCollection-&gt;methodNotAllowed(array('GET', 'HEAD')) in RouteCollection.php line 194
  at RouteCollection-&gt;getRouteForMethods(object(Request), array('GET', 'HEAD')) in RouteCollection.php line 142
  at RouteCollection-&gt;match(object(Request)) in Router.php line 716
  at Router-&gt;findRoute(object(Request)) in Router.php line 642
  at Router-&gt;dispatchToRoute(object(Request)) in Router.php line 618
  at Router-&gt;dispatch(object(Request)) in Kernel.php line 160
  at Kernel-&gt;Illuminate\Foundation\Http\{closure}(object(Request))
  at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 43
  at VerifyCsrfToken-&gt;handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 17
  at VerifyCsrfToken-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 125
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 55
  at ShareErrorsFromSession-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 125
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 61
  at StartSession-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 125
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
  at AddQueuedCookiesToResponse-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 125
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 40
  at EncryptCookies-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 125
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
  at CheckForMaintenanceMode-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 125
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
  at Pipeline-&gt;then(object(Closure)) in Kernel.php line 111
  at Kernel-&gt;sendRequestThroughRouter(object(Request)) in Kernel.php line 84
  at Kernel-&gt;handle(object(Request)) in index.php line 53
  </code></pre>