I have searched like crazy and can’t find or don’t understand the solutions to reloading an XML file that I’m reading with AJAX.
I’m looking for a way to refresh this XML when the page is refreshed so I know that the data is up to date. It only needs to happen when the page is reloaded.
one solution suggested something like this
[CODE]var xmlhttp;
function loadNewsContent(url)
{
var nocache = Math.random();//fix for IE who keeps the requested file in cache
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=stateChange;
xmlhttp.open(“GET”,url+’&nocache=’+nocache,true);
xmlhttp.send(null);
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
xmlhttp.onreadystatechange=stateChange;
xmlhttp.open(“GET”,url+’&nocache=’+nocache,true);
xmlhttp.send();
}
}
But that doesn’t work at all and I don’t know why. I’m new to this stuff so please try and provide complete answers as I have seen a pile of answers that just say “use this line..” and I can’t make heads or tails of it.
Thanks.