title: Why I obtain this exception when I try to handle an AJAX request with a Laravel controller method?
body: <p>I am absolutely new in PHP and Laravel and I have the following problem.</p>
  <p>From my view I perform an AJAX <strong>POST</strong> request via JQuery, by this code:</p>
  <pre><code>jQuery.ajax({
    url: '/doSearch',
    type: 'POST',
    dataType: 'json',
    //data: $form.serialize(),
    success: function(data){
     console.info('ssssssssssiiii',data);
       },
       error: function(data, b){
     console.info('erroreeeeee');
       }
   });
  </code></pre>
  <p>This <strong>POST</strong> request is handled by this simple controller method:</p>
  <pre><code>public function doSearch(){
      echo 'SEARCHED';
  }
  </code></pre>
  <p>that have to return the view the <strong>SEARCHED</strong> string.</p>
  <p>The problem is that I am obtaining this error message:</p>
  <pre><code>http://localhost:8000/doSearch 500 (Internal Server Error)
  </code></pre>
  <p>that is create by this exception casauted by a <strong>TokenMismatchException</strong>, in the Laravel stackrace I can see something like this:</p>
  <pre><code>in VerifyCsrfToken.php line 68
  at VerifyCsrfToken-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 137
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
  at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
  at ShareErrorsFromSession-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 137
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
  at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
  at StartSession-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 137
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
  at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
  at AddQueuedCookiesToResponse-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 137
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
  at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
  at EncryptCookies-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 137
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
  at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
  at Pipeline-&gt;then(object(Closure)) in Router.php line 644
  at Router-&gt;runRouteWithinStack(object(Route), object(Request)) in Router.php line 618
  at Router-&gt;dispatchToRoute(object(Request)) in Router.php line 596
  at Router-&gt;dispatch(object(Request)) in Kernel.php line 267
  at Kernel-&gt;Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
  at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
  at CheckForMaintenanceMode-&gt;handle(object(Request), object(Closure)) in Pipeline.php line 137
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
  at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
  at Pipeline-&gt;then(object(Closure)) in Kernel.php line 149
  at Kernel-&gt;sendRequestThroughRouter(object(Request)) in Kernel.php line 116
  at Kernel-&gt;handle(object(Request)) in index.php line 54
  at require_once('C:\xampp\htdocs\www.betrivius.it\application\public\index.php') in server.php line 21
  </code></pre>
  <p>What could be the problem? How can I solve this issue?</p>