I am using a native AJAX request to insert node values into HTML divs. However, I have noticed that when I update the XML values and upload them to the server while the website is running, Chrome and IE do not immediately reflect the changes (even after reloading with Shift-F5), and Firefox updates after some time (but not after the 1000ms interval set).
Here is the AJAX script in the HTML file:
<script>
//----BEGINNING OF AJAX REQUEST
function loadXMLDoc()
{
var xmlhttp;
var txt,x,i;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
xmlDoc=xmlhttp.responseXML;
txt="";
x=xmlDoc.getElementsByTagName("Value");
txt=x[0].childNodes[0].nodeValue;
document.getElementById("Eingabe_Web").innerHTML=txt;
txt=x[1].childNodes[0].nodeValue;
document.getElementById("differenzdruck").innerHTML=txt;
// more nodes being inserted into different divs...
}
}
xmlhttp.open("GET","einlesen.xml",true);
xmlhttp.send();
document.getElementById("refresh").innerHTML = new Date().getTime();
}
var refresh = window.setInterval("loadXMLDoc()",1000);
//----END OF AJAX REQUEST
</script>
The XML file structure is as follows:
<Values>
<Value><![CDATA[<img src="status-gruen:="Eingabe_Web":.png" style="width:35px;"/>]]></Value>
<Value><![CDATA[:="Differenzdruck_Web":]]></Value>
// more values being defined...
</Values>