AJAX bliver ved med at returnere readyState=0
Hey,Jeg sidder og roder med et lille chat-script jeg skal have lavet mig - men AJAX tager lidt af mig!
WWW: http://rapsac.net/rChat/
java script: http://rapsac.net/rChat/httpRequest.js
------------------------------------------------
var xmlHttp;
function GetXmlHttpObject(){
xmlHttp = null;
try{
//FIREFOX, OPERA, SAFARI
xmlHttp = new XMLHttpRequest();
}
catch(e){
try{
//INTERNET EXPLORER
xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
}
catch(e){
try{
xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
}
catch(e){
alert('Your browser does not support AJAX! The unit cost field will not automatically update depending on your expense category selection. Please enter this information manually.');
return false;
}
}
}
return xmlHttp;
}
function stateChanged(){
alert("In statChanged");
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
var val;
val = xmlHttp.responseText;
alert("We are now in!");
}
alert("State:" + xmlHttp.readyState);
}
function loadURL(){
xmlHttp = GetXmlHttpObject();
if(xmlHttp == null){
alert("Your browser is outdated and does not support AJAX.");
return;
}
var url = "testfile.php";
alert(url);
xmlHttp.onreadystatechange = stateChanged();
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
------------------------------------------------
Som sagt returnerer den at stateChanged er lig 0 - HVORFOR?
/Rapsac
