Skip to content

Instantly share code, notes, and snippets.

@amixpal
Created November 18, 2017 06:38
Show Gist options
  • Save amixpal/fcb3065a509abf6e71bcc25348fedb4d to your computer and use it in GitHub Desktop.
Save amixpal/fcb3065a509abf6e71bcc25348fedb4d to your computer and use it in GitHub Desktop.
function SubmitLoginForm() {
$("#loginform").validator().submit(function(e) {
if (e.isDefaultPrevented()) {
return;
} else {
e.preventDefault();
}
var _email = $("#emailid").val();
var _pass = $("#password").val();
var loginData = {
email: _email,
password: _pass,
guid: 'wkdhwdw9889d9wa8dkjk1ddawdaw'
};
$.ajax({
type: "POST",
dataType: "json",
url: 'http://localhost:9000/v1/admin/login',
data: JSON.stringify(loginData),
headers: {
'Content-type': 'application/json',
},
success: function(response) {
if (response.success == true) {
$("#loginformerrdiv p").html("");
$("#loginformerrdiv").hide();
SendLoginRequest(_email);
} else {
$("#loginformerrdiv p").html(response.message);
$("#loginformerrdiv").show();
}
},
error: function(response) {
if (response && response.responseJSON && response.responseJSON.error) {
$("#loginformerrdiv p").html(response.responseJSON.error);
$("#loginformerrdiv").show();
} else {
$("#loginformerrdiv p").html(GenericErrorMessage);
$("#loginformerrdiv").show();
}
}
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment