I am trying to create a scoreboard that refreshes its xml data with setInterval but when I use that the information shows up underneath itself over and over again instead of replacing the data that showed the first time. How would I get the information to replace itself instead of copying itself underneath over and over?
<script type="text/javascript">
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false);
xhttp.send();
return xhttp.responseXML;
}
setInterval(function() {
xmlDoc=loadXMLDoc("http://ift.tt/1BAMxmI");
var x=xmlDoc.getElementsByTagName("game");
for (i=0;i<x.length;i++){
var gameStatus = x[i].getAttribute('status');
document.write(gameStatus + "<br>");
}
}, 3000);
</script>
No comments:
Post a Comment