$(document).ready(function() { $("#st_loginform").submit(function(){ var error = ""; $("#st_loginform button[type='submit']").html('Please wait'); $("#st_loginform button[type='submit']").attr("disabled","true"); $.ajax({ url: "https://wbchseapp.wb.gov.in/portal/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; 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); // window.history.go(-1); return false; window.location='dashboard_student'; } 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; }); }); function refreshCaptcha(){ var img = document.images['captchaimg']; img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000; }