title: Submitting A Laravel Login Form with jQuery Ajax
body: <p>I have a login form that I"m trying to figure out how I can have it validate with my jQuery validation and as well as have it submit with ajax to the process function in my LoginController. I'm not sure what I am needing to do to accomplish this because of needing a route or not.</p>
  
  <pre><code>&lt;?php
  Route::get('login', array('uses' =&gt; 'LoginController@index'));
  Route::post('login', array('uses' =&gt; 'LoginController@process'));
  
  ?&gt;
  
  &lt;?php
  
  class LoginController extends \BaseController {
  
      /**
      * Display the login form for a user to log into.
      *
      * @return Response
      */
      public function index()
      {
          // Display login form.
          return View::make('login');
      }
  
      /**
      * Process the login from the user.
      *
      * @return Response
      */
      public function process()
      {
          /*
          //return 'This is the process function for the login controller.';
          $rules = array(
             'email' =&gt; 'required|email',
             'password' =&gt; 'required|alphaNum|min:3'
          );
  
          $validator = Validator::make(Input::all(), $rules);
  
          // if the validator fails, redirect back to the form
          if ($validator-&gt;fails()) {
              return Redirect::to('login')-&gt;withErrors($validator)-&gt;withInput(Input::except('password'));
          } else {
              // validation passed continue to validate post data.
              return 'validation passed';
          }
  
          */
          return Response::json(array('name' =&gt; 'Steve', 'state' =&gt; 'CA'));
       }
  }
  
      &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"&gt;
      &lt;meta name="description" content=""&gt;
      &lt;meta name="author" content=""&gt;
  
      &lt;title&gt;Chain Responsive Bootstrap3 Admin&lt;/title&gt;
  
      &lt;link href="assets/css/style.default.css" rel="stylesheet"&gt;
  
      &lt;!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --&gt;
      &lt;!--[if lt IE 9]&gt;
      &lt;script src="assets/js/html5shiv.js"&gt;&lt;/script&gt;
      &lt;script src="assets/js/respond.min.js"&gt;&lt;/script&gt;
      &lt;![endif]--&gt;
  &lt;/head&gt;
  
  &lt;body class="signin"&gt;
  
  
      &lt;section&gt;
  
          &lt;div class="panel panel-signin"&gt;
              &lt;div class="panel-body"&gt;
                  &lt;div class="logo text-center"&gt;
                      &lt;img src="assets/images/logo-primary.png" alt="Chain Logo"&gt;
                  &lt;/div&gt;
                  &lt;br/&gt;
                  &lt;h4 class="text-center mb5"&gt;Already a Member?&lt;/h4&gt;
  
                  &lt;p class="text-center"&gt;Sign in to your account&lt;/p&gt;
  
                  &lt;div class="mb30"&gt;&lt;/div&gt;
  
                  {{ Form::open(array('url' =&gt; 'login', 'id' =&gt; 'loginForm')) }}
  
                      &lt;div class="input-group mb15"&gt;
                          &lt;span class="input-group-addon"&gt;&lt;i class="glyphicon glyphicon-user"&gt;&lt;/i&gt;&lt;/span&gt;
                          {{ Form::text('email_address', Input::old('email_address'), array('placeholder' =&gt; 'Email Address', 'class' =&gt; 'form-control')) }}
                      &lt;/div&gt;
  
                      &lt;!-- input-group --&gt;
                      &lt;div class="input-group mb15"&gt;
                          &lt;span class="input-group-addon"&gt;&lt;i class="glyphicon glyphicon-lock"&gt;&lt;/i&gt;&lt;/span&gt;
                          {{ Form::password('password', array('placeholder' =&gt; 'Password', 'class' =&gt; 'form-control')) }}
                      &lt;/div&gt;
                      &lt;!-- input-group --&gt;
  
                      &lt;div class="clearfix"&gt;
                          &lt;div class="pull-left"&gt;
                              &lt;div class="ckbox ckbox-primary mt10"&gt;
                                  &lt;input type="checkbox" id="rememberMe" value="1" name="rememberMe"&gt;
                                  &lt;label for="rememberMe"&gt;Remember Me&lt;/label&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
  
                          &lt;div class="pull-right"&gt;
                              &lt;button type="submit" class="btn btn-success"&gt;Sign In &lt;i class="fa fa-angle-right ml5"&gt;&lt;/i&gt;
                              &lt;/button&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  
                  {{ Form::close() }}
  
              &lt;/div&gt;
              &lt;!-- panel-body --&gt;
              &lt;div class="panel-footer"&gt;
                  &lt;a href="signup" class="btn btn-primary btn-block"&gt;Not yet a Member? Create Account Now&lt;/a&gt;
              &lt;/div&gt;
              &lt;!-- panel-footer --&gt;
          &lt;/div&gt;
          &lt;!-- panel --&gt;
  
      &lt;/section&gt;
  
      &lt;script src="assets/js/jquery-1.11.1.min.js"&gt;&lt;/script&gt;
      &lt;script src="assets/js/jquery-migrate-1.2.1.min.js"&gt;&lt;/script&gt;
      &lt;script src="assets/js/jquery-ui-1.10.3.min.js"&gt;&lt;/script&gt;
      &lt;script src="assets/js/bootstrap.min.js"&gt;&lt;/script&gt;
      &lt;script src="assets/js/modernizr.min.js"&gt;&lt;/script&gt;
      &lt;script src="assets/js/pace.min.js"&gt;&lt;/script&gt;
      &lt;script src="assets/js/retina.min.js"&gt;&lt;/script&gt;
      &lt;script src="assets/js/jquery.cookies.js"&gt;&lt;/script&gt;
      &lt;script src="assets/js/jquery.validate.min.js"&gt;&lt;/script&gt;
  
      &lt;script src="assets/js/custom.js"&gt;&lt;/script&gt;
  
      &lt;script&gt;
          $(document).ready(function(){
              // validate the login form from user input.
              $("#loginForm").validate({
                  debug: true,
                  submitHandler: function(form) {
                      $.ajax({
                          type: "POST",
                          url: 'login/process',
                          data: $("#loginForm").serialize(),
                          dataType: 'json',
                          success: function(data)
                          {
                             alert(data);
                          }
                       });
  
                      return false;
                  }
              });
          });
      &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>