Loading a file on the server - timing issues?



I am loading a text file to a variable with XMLHttpRequest()
There seems to be some sort of timing issue since loadXML (source code below)
returns the contents of the file on seconds try. In Firefox I get an empty
string. No errors are reported.

If I look at the code with Firefox debugger (Venkman) everything works fine. I
should probably put a loop somewhere to check when loading the file is finished.


var xmlhttp;
...
[a lot of Javascipt code here]
...
loadXMLDoc("http://wwww.mysite.com/test.bin";);
mystr=xmlhttp.statusText;
...


function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
{// code for IE7, Firefox, Opera, etc.
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
else
{
alert("Browser not supported.");
}
}

function state_Change()
{
if (xmlhttp.readyState==4)
{// 4 = "loaded"
if (xmlhttp.status!=200)
{
alert("Problem:" + xmlhttp.statusText);
}
}
}
.



Relevant Pages

  • Re: Using XMLHttpRequest in Firefox
    ... > Trevor L. wrote: ... >> THIS ALERT DISPLAYS IN FIREFOX ... > for XMLHttpRequest. ... Here is the code from W3schools ...
    (microsoft.public.scripting.jscript)
  • Re: Safari for Windows
    ... Having done a lot of testing of "page loads faster" claims back in ... clock when the loading indicator disappeared, ... Firefox took 17 ... How do they compare loading web sites after being started? ...
    (rec.outdoors.rv-travel)
  • Re: Mozilla/Firefox 1.5 is excellent!. Much better than IE...
    ... thing that needs loading is the new stuff in an updated web page. ... extension called Fasterfox. ... user's Firefox browser slowed down a lot after a month. ... The theory seemed to be that viruses ...
    (microsoft.public.windowsxp.general)
  • facebook texas poker game not works
    ... I am facing problem to load poker game in facebook.com. ... firefox of microsoft but no result with mozilla but with opera it is loading ...
    (Ubuntu)
  • Re: Konqueror vs Firefox
    ... > loaded the forty cartoons that I mentioned. ... > whole time that the forty sites were loading without any problems. ... Still no problem scrolling up and down on the original page. ... Firefox is still my browser of choice, ...
    (Fedora)

Loading