MrFish Posted June 29, 2009 Share Posted June 29, 2009 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- Link to comment Share on other sites More sharing options...
justsomeguy Posted June 29, 2009 Share Posted June 29, 2009 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 More sharing options...
MrFish Posted June 30, 2009 Author Share Posted June 30, 2009 You get the cookie! Enjoy it.the function was ajaxlogin() but the onClick called "ajaxLogin()" (with a capital). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.