Hi all. I 'm having some trouble with my javascript code calling my php. Does anyone see an error in the following code? I swear I'm using code just like this on another part of the site...
var xmlHttp = createXmlHttpRequestObject();
var favSongArray = [];
function createXmlHttpRequestObject(){
var xmlHttp;
try{
xmlHttp = new XMLHttpRequest();
}
catch(e){
var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
"MSXML2.XMLHTTP.5.0",
"MSXML2.XMLHTTP.4.0",
"MSXML2.XMLHTTP.3.0",
"MSXML2.XMLHTTP",
"Microsoft.XMLHTTP");
for(var i = 0; i < XmlHttpVersions.length && !xmlHttp; i++){
try{
xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
}
catch(e){}
}
}
if(!xmlHttp){
alert("Error creating the XMLHttpRequest object.");
}
else{
return xmlHttp;
}
}
function process(){
if(xmlHttp){
alert("sever is available");
//if yes try
try{
xmlHttp.open("GET", "php/getUntimed.php", true);
xmlHttp.onreadystatechange = function(){handleRequestStateChange();};
alert("attempted to call p_handleRequestStateChange_test");
xmlHttp.send(null);
}//end try
catch(e){
alert("Can't connect to server: \n" + e.toString());
}//end catch
}//end if xmlHHttp
}//end function
function handleRequestStateChange(){
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
try{
u_handleServerResponse();
}//end try
catch(e){
alert("Error reading the response: " +e.toString());
}//end catch
}//end if
else{
alert("There was a problem retriving the data:\n" + xmlHttp.statusText);
}//end else
}//end if
}//end function
function u_handleServerResponse(){
//need to clear array each time
var response = xmlHttp.responseText;
favSongArray = response.split("+");
alert("made it here");
//getFlashMovie("trackTimer").trackTimer(favSongArray[0]);
}
process() is called from an onSubmit trigger. I keep getting a xmlHttp.status of zero. Does that make sense to anyone? Thanks