Jump to content

Ajax Login Won't Work.


MrFish
 Share

Recommended Posts

Here is my javascript/html page. I've already concluded that the php side works (I've tried it separately) and it's just the javascript.

alert("1");function ajaxlogin(){	alert("1a");	var ajaxRequest;	alert("1b");	if(window.XMLHttpRequest){		ajaxRequest = new XMLHttpRequest();		alert("a");	} else if(window.ActiveXObject){			ajaxRequest = new ActiveXObject("Msxml1.XMLHTTP");			alert("b");		} else {			alert("Your browser broke!");		}	alert("2");	ajaxRequest.onreadystatechange = function(){		if(ajaxRequest.readyState == 4){			getelementbyid("loginbox").innerHTML = ajaxRequest.responseText;			alert("d");		}	}	alert("3");	var username = login.username.value;	var password = login.password.value;		alert(username + " " + password);		ajaxRequest.open("POST", "includes/login.php", "true");	ajaxRequest.send(null);	alert("4");}

I've set up alerts everywhere to see where the problem is. The first alert goes off when the page starts, but once you click the login button I never get anymore. This problem is probably because there is a syntax error but I can't find it! Can anyone look through it and tell me what I did wrong?Whoever can find it gets this cookie-cookie%20b.jpg

Link to comment
Share on other sites

Javascript is case-sensitive, "getelementbyid" is not a defined function name. For these lines:var username = login.username.value;it doesn't look like the login variable is defined.Those are runtime errors though, not compile-time errors. If the alert 1a never shows that means the function is never getting called. The things I mentioned above are errors, but they're not going to be triggered until the function runs.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...