Click to See Complete Forum and Search --> : Refresh <div>?


steeleye
03-04-2008, 05:32 PM
I need to display a one-line text file in a <div> and have it refresh every 20 seconds without disturbing the rest of the page. Is there a way to do that?

Here is the javascript I have tried, but it does not refresh the <div> as intended:

...In the <head> section

<script language="javascript">
function GetSong(){
var url = "http://kevinsmithshow.com/program/CurrentSong.txt";
var xmlhttp=new ActiveXObject("microsoft.xmlhttp");
try {
xmlhttp.open("GET", url, false);
xmlhttp.send();
var data=xmlhttp.responsetext;
current.innerHTML=data;
} catch (e2) {
}
}
</script>

<script language="javascript">
function reloadIt()
{
GetSong();
setTimeout("reloadIt()",20000);
}
</script>


... In the <body> section

<div id="title"><font color="#003366" size="2" face="Geneva, Arial, Helvetica, sans-serif"><b><i>NOW
PLAYING:</i></b></font></div>
<marquee>
<div id="current" font face="arial" color="white"></div>
</marquee>
<script language="JavaScript">reloadIt();</script>
</font></div>


I do apologize if this has been addressed elsewhere. I searched the forums and did not find anything about this issue.

Thanks.

toenailsin
03-04-2008, 07:41 PM
use setInterval instead of setTimeout

steeleye
03-04-2008, 07:48 PM
Thank you toenailsin. I will give it a spin.