Last active
January 3, 2016 20:19
-
-
Save infacq/8514279 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
login: function (event) { | |
event.preventDefault(); // Don't let this button submit the form | |
$('.alert').remove(); // Hide any errors on a new submit | |
var url = './service/login'; | |
$('.btn-login').button('loading'); | |
var formValues = { | |
email: $('#tEmail').val(), | |
pwd: $('#tPwd').val() | |
}; | |
$.ajax({ | |
url:url, | |
type:'POST', | |
dataType:"json", | |
data: formValues, | |
success:function (data) { | |
if(data.error) { | |
$('.alert').remove(); | |
$('.login-wrap').prepend('<div class="alert alert-warning alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><strong>Warning!</strong> '+data.error.text+'</div>'); | |
$('#tEmail').select().focus(); | |
} else { | |
$.ajaxSetup({ | |
headers: {'X-CSRF-Token': data.token} | |
}); | |
Backbone.history.navigate("/", { trigger: true, replace: true }); | |
} | |
$('.btn-login').button('reset'); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment