title: laravel TokenMismatchException in ajax request
body: <p>i'm using resource group and use this filter to resolve <code>TokenMismatchException</code> problem:</p>
  
  <pre><code>Route::filter('csrf', function($route, $request) {
      if (strtoupper($request -&gt; getMethod()) === 'GET') {
          return;
          // get requests are not CSRF protected
      }
  
      $token = $request -&gt; ajax() ? $request -&gt; header('X-CSRF-Token') : Input::get('_token');
  
      if (Session::token() != $token) {
          throw new Illuminate\Session\TokenMismatchException;
      }
  });
  </code></pre>
  
  <p>my route :</p>
  
  <pre><code>Route::group(array('prefix'=&gt; 'admin', 'before' =&gt; 'csrf'), function(){
      Route::resource('profile' , 'ProfileController', array('as'=&gt;'profile') );
  });
  </code></pre>
  
  <p>now. i get error to Ajax requests such as this code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function() {
         $('#frm').submit(function(e){
             e.preventDefault();
             name         = $('#name').val();
             family       = $('#family').val();
             email        = $('#email').val();
             currPassword = $('#currPassword').val();
             password     = $('#password').val();
             password_confirmation = $('#password_confirmation').val();     
  
             $.post("{{ route('admin.profile.update', $profile-&gt;id) }}",
                  { 
                    _method : 'PUT',
                    name                  : name,
                    family                : family,
                    email                 : email,
                    currPassword          : currPassword,
                    password              : password,
                    password_confirmation : password_confirmation  
                  },
                  function(data)
                  {
                      alert(data.errors.name);
                  },'json');
                  return false;
         });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>ERROR:</p>
  
  <pre><code>{"error":{"type":"Illuminate\\Session\\TokenMismatchException","message":"","file":"\/var\/www\/alachiq\/app\/filters.php","line":83}}
  </code></pre>
  
  <p>i think i'm must be sent _token in <code>$.post</code>. but i can not get <code>input</code> tag with <code>name</code> attribute. iget this error:</p>
  
  <pre><code>TypeError: 'stepUp' called on an object that does not implement interface HTMLInputElement.
  </code></pre>