私はjavascript、特にajaxが初めてです..そして、それを理解しようとしています..
あるチュートリアルからこのコードを書きましたが、何が間違っていたのかわかりません。生で見られるのはこちら
Firebug から取得しているエラー:「TypeError: xmlhttp は未定義です [Break On This Error]
もし (xmlhttp.readyState == 4){"
私のコードは
// 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