Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ajax login
<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
You can’t perform that action at this time.