The idiot that wrote the code for the Intro to AJAX tutorial made a mistake:
var xmlHttp;
function createRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function ajax(){
createRequest();
var url = "ajax2.php?test=hello!";
xmlHttp.open("GET";, url, true);
xmlHttp.onreadystatechange = StateChange;
xmlHttp.send(null);
}
function StateChange(){
if(xmlHttp.readyState == 4){
alert(xmlHttp.responseText);
}}
Should be:
var xmlHttp;
function createRequest(){
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function ajax(){
createRequest();
var url = "ajax2.php?test=hello!";
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = StateChange;
xmlHttp.send(null);
}
function StateChange(){
if(xmlHttp.readyState == 4){
alert(xmlHttp.responseText);
}}