phpSensei Posted March 10, 2008 Share Posted March 10, 2008 Hello everyone, I am still on the quest of exploring this wonderful language, javascript and ajax. Although i came by some problems which doesn't occur IE7 or 6, but only FireFox... Don't know if its something with ajax or javascript... sendObj has no properties on line 49 Line 47,48,49..etc 48: } 49: 50: } else{ 51: 52: sendObj.open('get','validateLogin.php?username='+username+'&password='+password); sendObj.onreadystatechange = handleLogin; sendObj.send(null); } } Script <script language="JavaScript" type="text/javascript"> function createObject(){ var Req; if(window.XMlHttpRequest){ Req = new XMLHttpRequest(); }else if(window.ActiveXObject){ Req = new ActiveXObject("Microsoft.XMLHTTP"); } return Req; } var getObj = createObject(); var sendObj = createObject(); function userLogin(){ var username = document.getElementById('user').value; var password = document.getElementById('pass').value; if(username == '' || password == ''){ alert('Please enter your username and password'); if(username == ''){ document.getElementById('user').focus(); }else{ document.getElementById('pass').focus();} } else{ sendObj.open('get','validateLogin.php?username='+username+'&password='+password); sendObj.onreadystatechange = handleLogin; sendObj.send(null); } } function handleLogin(){ if(sendObj.readyState == 1){ document.getElementById('stats').innerHTML = '<img src="../../ims/loader.gif">'; document.getElementById('loginBTN').innerHTML = 'Processing Login...'; } else if(sendObj.readyState == 4 && sendObj.status == 200){ // 1 wrong username // 2 empty // 3 logged in document.getElementById('stats').innerHTML = '<span class="red">Try Again </span>'; document.getElementById('loginBTN').innerHTML = '<a href="javascript:userLogin();">Log In</a>'; var response = sendObj.responseText; if(response == '1'){ alert('Wrong Username or Password'); }else if(response == '2'){ alert('Empty Field Detected, possible hack attempt'); }else{ window.location = '../../index.php'; } } } </script> Quote Link to comment Share on other sites More sharing options...
phpSensei Posted March 10, 2008 Author Share Posted March 10, 2008 Nvm, im an idiot I fixed it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.