By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,466 Members | 1,138 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,466 IT Pros & Developers. It's quick & easy.

ajax loading problem

P: 2
I have used an ajax file furnaces.html with code as below.The file furnacedata.php is used to generate XML dynamically and this appears to working well. timerID is used to reload the XML data at intervals of 1000ms. This code appears to be working in some PCs and not in others. It is not giving a reliable output. can anybody help?

Code:
[HTML]<head>
<script language="JavaScript" type="text/JavaScript">
[/HTML]
Expand|Select|Wrap|Line Numbers
  1. function getfurnacedata()
  2. {
  3. var XMLHttpRequestObject = false;
  4.  
  5.      if (window.XMLHttpRequest) {
  6.        XMLHttpRequestObject = new XMLHttpRequest();
  7.        XMLHttpRequestObject.overrideMimeType("text/xml");
  8.      } else if (window.ActiveXObject) {
  9.        XMLHttpRequestObject = new
  10.          ActiveXObject("Microsoft.XMLHTTP");
  11.      }
  12.  
  13.   if(XMLHttpRequestObject) {
  14.     XMLHttpRequestObject.open("GET", "furnacedata.php");
  15.     XMLHttpRequestObject.onreadystatechange = function()
  16.     {
  17.       if (XMLHttpRequestObject.readyState == 4 &&
  18.         XMLHttpRequestObject.status == 200) {
  19.       var xmlDocument = XMLHttpRequestObject.responseXML;
  20.         var1data1 = xmlDocument.getElementsByTagName("var1data1");
  21.         var1data2 = xmlDocument.getElementsByTagName("var1data2");
  22.     var1data3 = xmlDocument.getElementsByTagName("var1data3");
  23.     var1data4 = xmlDocument.getElementsByTagName("var1data4");
  24.              document.getElementById("ID1").innerHTML=var1data1[0].firstChild.nodeValue;
  25.     document.getElementById("ID2").innerHTML=var1data2[0].firstChild.nodeValue;
  26.     document.getElementById("ID3").innerHTML=var1data3[0].firstChild.nodeValue;
  27.     document.getElementById("ID4").innerHTML=var1data4[0].firstChild.nodeValue;
  28.  
  29.       }
  30.     }
  31.  
  32.     XMLHttpRequestObject.send(null);
  33.   }
  34. }
  35.  
[HTML]
</script>
</head>
<body>
//all the variables are outputted here against the tag IDs

<script language="JavaScript" type="text/JavaScript">
timerID=setInterval("getfurnacedata()",1000);
</script>
</body>[/HTML]
Nov 2 '07 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Maybe one second is too soon. Try 5 seconds.
Nov 2 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.