Jump to content

AJAX


will71110

Recommended Posts

So I have this project I'm suppose to be doing. It's to make a web page using AJAX to update a page every 5 seconds, stop/start when a button is pushed, and dynamically update when the back end XML is updated. The problem I have is that it isn't updating (FTP) right after I change the XML. It takes like 5 to 10 mins for it to actually update. here is the code:

<script type="text/javascript">var z = 0;var repeatIDfunction halter(url){  if (repeatID){   clearInterval(repeatID)   repeatID = null   document.getElementById('ChangeMe').innerHTML = "Message paused";  }  else{   loadXMLdoc(url)    }}function loadXMLdoc(url) {   var xmlhttp   var txt   if (window.XMLHttpRequest) {	xmlhttp = new XMLHttpRequest();   } else {	xmlhttp = new ActiveXObject("microsoft.XMLHTTP");   }   repeatID = window.setInterval(function() {   xmlhttp.open("GET", url, true);   xmlhttp.send();   xmlhttp.onreadystatechange = function() {	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {	 x = xmlhttp.responseXML.documentElement	   .getElementsByTagName('message');	 if (z < x.length) {	  xx = x[z].getElementsByTagName("content")	  txt = xx[0].firstChild.nodeValue	  z += 1	  if (z == x.length){	  z = 0	  }	}	}	 document.getElementById('ChangeMe').innerHTML = txt;   }  }, 1000);}</script>

Is it in my script or is my browser doing something it's not suppose to??

Edited by will71110
Link to comment
Share on other sites

Well I figured out that Chrome caches content for around 20 mins. After the 20 mins, my content will update. I'm still new at this so make a link that is time stamped is beyond me currently. Hopefully soon I'll get a better understanding of this and can do like you said justsomeguy.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...