Code:
function process_login(){
var login_ajax = ajaxpack.ajaxobj;
if(login_ajax.readyState === 4 && login_ajax.status === 200 ){
if(login_ajax.responseText && trim(login_ajax.responseText) === "1"){
alert('Checking berhasil, silahkan click "Login Now');
document.forms['login_form'].elements['login_button'].style.display="none";
document.forms['login_form'].elements['login_submit'].style.display="block";
}else{
alert(login_ajax.responseText);
document.forms['login_form'].elements['login_button'].disabled="";
document.forms['login_form'].elements['login_button'].value = "try again";
}
}
}
function trim(str) {
if (!str || typeof str != 'string') return null;
return str.replace(/^[\s]+/, '').replace(/[\s]+$/, '').replace(/[\s]{2,}/, ' ');
}
Comment your version of process_login method and try mine and put the trim function also inside script element. Actually as a false server response it is not '0' coming from the server but a message.
Make sure that you are sending the text '1' in case of success in case of failure anything is ok.
Bookmarks