I Please need to read xml file. If xml file changes i need to see the change in the index.html page, without reloading the entire page.
my code seems to work only on my local computer.
if i upload the code on the internet (on a Linux Hosting) the index.html reads xml file, but, if xml file changes, the index.html page never show any updates.
i noticed the two following :
after xml file changes (from another external script that updates the xml file), index.html does not update,
if i open "index.html" with mozilla firefox and press F5 to reload index.html page, it reloads that page, but never update data (still read old data from xml file).
if i open "data.xml" with mozilla firefox and i press F5, this will force the "index.html" to update.
of course none of the two above are considered a solution, because it has to work automatically without user interference, and of course without reloading the entire page.
Any help appreciated. Thanks.
this is my code
"index.html"
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"></head>
<body>
<div id="f1"></div><br>
<script>
function foo() {
console.log("foo");
var xmlhttp;
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "data.xml", false);
xmlhttp.send();
var xmlDoc = xmlhttp.responseXML;
var f1 = xmlDoc.getElementsByTagName("f1")[0].childNodes[0].nodeValue;
document.getElementById("f1").innerHTML = f1;
}
function onload() {
console.log("onload");
foo();
setInterval(function(){
foo();
}, 2000);
}
onload();
</script>
</body>
</html>
this is data.xml
<?xml version="1.0" encoding="UTF-8"?>
<outer>
<inner>
<f1>174</f1>
</inner>
</outer>