heres the deal. heres my site:
[url]http://webfiles.dreamhosters.com/qm
in that site, essentially, i have 3 pages in my ajax program:
[URL=”http://webfiles.dreamhosters.com/qm/”]index.php
[URL=”http://webfiles.dreamhosters.com/qm/list_get.php”]list_get.php
[URL=”http://webfiles.dreamhosters.com/qm/list_show.php”]list_show.php
so for example, index.php fires off this ajax scripting:
[code]function getList()
{
if(refresh == -1)
refresh = 0;
else if(refresh == 1)
{
refresh =0;
document.getElementById(“refresh”).innerHTML = “<img src=”images/refresh_all_2.jpg” title=”Retrieving server list…”>”;
}
else
return;
xmlHttp = GetXmlHttpObject();
if(xmlHttp==null)
{
alert (“Your browser does not support AJAX!”);
return;
}
var url = “list_get.php?sid=” + Math.random();
xmlHttp.onreadystatechange = getListChanged;
xmlHttp.open(“GET”,url,true);
xmlHttp.send(null);
}
function getListChanged()
{
if (xmlHttp.readyState==4)
{
response = xmlHttp.responseText.split(“n”);
for(x in response)
output += response[x] + “<br>”; // debug info is displayed
document.getElementById(“writehere”).innerHTML = output;
serverInfo();
}
}
the innerHTML stuff is just outputting the debug info. then my next ajax request is called via serverInfo():
[code]function serverInfo()
{
xmlHttp = GetXmlHttpObject();
if(xmlHttp == null)
{
alert (“Your browser does not support AJAX!”);
return;
}
var url = “list_show.php?sid=” + Math.random();
xmlHttp.onreadystatechange = serverInfoChanged;
xmlHttp.open(“GET”,url,true);
xmlHttp.send(null);
theStart = new Date().valueOf();
}
var serverArray = new Array(); // [B]NOTICE THIS IS IN GLOBAL CONTEXT[/B]
function serverInfoChanged()
{
document.getElementById(“content”).innerHTML += “waiting for a response..<br>”
if(xmlHttp.readyState==4)
{
refresh = 1;
var theVal = new Date().valueOf();
var split = theVal – theStart;
// all we are doing is making it look nice here
document.getElementById(“content”).innerHTML += xmlHttp.responseText.replace(/);/g,”);<br>”);
// remove apostrophes from the array or else it breaks
var theoutput = xmlHttp.responseText.replace(/’/g,””)
// output the raw response we got from list_show.php
document.getElementById(“writehere”).innerHTML += “<br><br>” + xmlHttp.responseText
// actually try and run the apostrophe replace info
eval(theoutput)
// at this point, if an error occurs, it was because of data loss
}
}
i was thinking that “list_get.php” and the PHP was the culprit, but when i copy all the text from that page “list_get.php” (by directly navigating to it), and then sticking it in the code below:
[code]
<script>
var serverArray = new Array()
// i place the copied text here
alert(“done.”)
</script>
i never have a problem getting the alert to fire. so the PHP cant possibly be the one dropping data sporadically. something is being lost during ajax transmission.
any idea why i would be getting this sporadic data loss? this only occurs in IE from what ive seen. navigate to my link above to test. if you get a prompt after all that array garbage is printed to that table, the code executed succesfully. SOMETIMES IE doesnt fail.