title: Laravel 4 CSRF form submit through Ajax call
body: <p>I'm new to both Stackoverflow and Laravel 4,
  I am trying to submit a form through jquery ajax. I serializeArray() the form and use json to submit it. 
  In laravel, in the routes I check the csrf token submitted, the go to my controller for process inputs.
  The csrf check doesn't work when the _token input is in an array as with serializeArray(). 
  I have to get the _token value and submit is as a seperate ajax data. I'm wondering if there is a way to tell csrf filter where ever its running to check the input array for hte field _token and use that? 
  here is my code:</p>
  
  <p>routes.php</p>
  
  <pre><code>Route::post('searchAjax', array('before' =&gt; 'csrf', 
                                  'uses' =&gt; 'SearchController@searchAjax'));
  </code></pre>
  
  <p>This is where I wan't it to read the array form[0]['_token] but I don't know how to tell it to do that.</p>
  
  <pre><code>index.js
      var form = $('#search').serializeArray();
  var token = $('#search &gt; input[name="_token"]').val();
  $.ajax({
      type: 'post',
      url: 'searchAjax',
      dataType: 'json',
      data: { _token: token, form: form },
      success: function(data) {
          for(var key in data)
          {
              //alert(key)
          }
          //alert(data.message);
      }
  });
  </code></pre>
  
  <p>I want to get rid of  { _token: token, form: form } in the ajax call and just have 'form' that is an array with _token in it already.
  here is the html:</p>
  
  <pre><code>&lt;form id="search" class="form-horizontal" accept-charset="UTF-8" action="http://testing:998/search" method="POST"&gt;
    &lt;input type="hidden" value="6GBbv9LmnOdL8UcOsm8DDJ4Bfi6eGcQRlC9SPdL4" name="_token"&gt;
  &lt;div class="control-group"&gt;
    &lt;label class="control-label" for="title"&gt;Book Titles&lt;/label&gt;
    &lt;div class="controls"&gt;
      &lt;input id="title" class="input" type="text" value="click to search book titles" name="title"&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="control-group"&gt;
  &lt;div class="control-group"&gt;
  &lt;div class="control-group"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Thank you in advance. :)</p>