Last active
October 6, 2016 08:54
-
-
Save keithmancuso/29e8446ec5fa66fb2b01 to your computer and use it in GitHub Desktop.
ajax login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form method="post" action="" id="login-form" accept-charset="UTF-8"> | |
<input type="hidden" name="action" value="users/login"> | |
<input type="hidden" name="redirect" value="{{redirect}}"> | |
<div class="form-group"> | |
<label for="email">Email</label> | |
<input id="email" type="text" name="loginName" class="form-control"> | |
</div> | |
<div class="form-group"> | |
<label for="password">Password</label></h3> | |
<input id="password" type="password" name="password" class="form-control"> | |
</div> | |
<div class="text-right"> | |
<input type="submit" value="Log In" class="btn btn-primary "> | |
</div> | |
</form> | |
<script> | |
$('#loginForm').submit( function (e ) { | |
e.preventDefault(); | |
var data = $(this).serialize(); | |
$.ajax({ | |
method: 'POST', | |
url: '/', | |
data: data, | |
headers: {'Content-Type': 'application/x-www-form-urlencoded'} | |
}) | |
.success(function(data) { | |
console.log('success', data); | |
}) | |
.error(function(data) { | |
console.log('error', data); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment