As a newcomer to javascript and ajax, I am trying my best to understand it all. I followed a tutorial to write this code, but I can't seem to figure out what I did wrong. If you click here, you can see the live version.
The error message that Firebug is showing me is: "TypeError: xmlhttp is undefined [Break On This Error]
This is the code I have written:
// JavaScript Document
var xmlhttp;
var url;
function ajaxFunction(){
if (window.ActiveXObject){//if the window is InternetExplorer
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){// if Window is Firefox etc..
xmmlhttp= new XMLHttpRequest();
}else{
alert ("Get a New Browser")
}
}//end of ajaxFunction()
function getInfo(){
ajaxFunction();
var entryInfo= document.getElementById("entry").value;
function stateChanged(){
if (xmlhttp.readyState == 4){
document.getElementById("results").innerHTML = xmlhttp.responseText;
}//if (xmlhttp.readyState == 4)
}//end of function stateChanged()
url = "info.php?user="+entryInfo;
xmlhttp.onreadystateshange=stateChanged();
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}// end of function getInfo