Hi. I am reading a text file using the following Javascript code.

function getXmlHttpRequestObject() {

if (window.XMLHttpRequest) {
return new XMLHttpRequest(); //Not IE
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP"); //IE
} else {
alert("Your browser doesn't support the XmlHttpRequest object.");

}
}

var Req = getXmlHttpRequestObject();

Req.open("GET", "fileName.txt", true);

Req.onreadystatechange = function() {
if (Req.readyState == 4) {
var output = Req.responseText;
}
}


It works fine, except that if a text file exists and is then overwritten, it will still read the old version rather than the current version.

For example, if I have a text file with the contents 'AAA', which is then saved again with the contents 'BBB', the code fails to refresh and still reads 'AAA'.

Closing the browser tab and reloading the page solves the problem, but I would like to find a solution which doesn't involve doing this.