$(document).ready(function() {
$("#st_loginform").submit(function(){
var error = "";
var url=$('#last_url').val();
$("#st_loginform button[type='submit']").html('Please wait');
$("#st_loginform button[type='submit']").attr("disabled","true");
$.ajax({
url: "https://wbtcemp.in/login-action",
type: "POST",
dataType:"json",
data: new FormData($("#st_loginform")[0]),
async: true,
contentType: false,
cache: false,
processData:false,
success: function(data) {
$("input[name='"+data.token_name+"']").val(data.token);
toast_type = data.type;
if(data.type=="success")
{
//return false;
window.location =url;
}
toastr.clear();
toastr.options = {
"closeButton": true,
"debug": false,
"newestOnTop": true,
"progressBar": false,
"positionClass": "toast-bottom-center",
"preventDuplicates": true,
"showDuration": "1000",
"hideDuration": "10000",
"timeOut": "2000",
"extendedTimeOut": "1000"
};
if(toast_type=='success')
{
$("#st_loginform button[type='submit']").html('Redirecting...');
toastr.success(''+data.text);
}
else
{
$("#st_loginform button[type='submit']").html('Sign In');
$("button[type='submit']").removeAttr("disabled");
toastr.warning(''+data.text);
}
},
error: function(xhr, ajaxOptions, thrownError) {
toastr.clear();
toastr.options = {
"closeButton": true,
"debug": false,
"newestOnTop": true,
"progressBar": false,
"positionClass": "toast-bottom-center",
"preventDuplicates": true,
"showDuration": "6000",
"hideDuration": "10000",
"timeOut": "3000",
"extendedTimeOut": "2000"
};
toastr.error(' Failed! Something is wrong.');
$("#st_loginform button[type='submit']").html('Sign In');
$("#st_loginform button[type='submit']").removeAttr("disabled");
}
});
return false;
});
});