[thelist] Actual Ajax question WAS: AJAX only mailing list

Jonathan Snook jonathan.snook at gmail.com
Wed Jul 11 20:54:26 CDT 2007


On 7/11/07, Brent Eades <beades at almonte.com> wrote:
> setInterval("updateInfo()", 3000);

This is the line that runs the function. Change it to assign itself to
a variable.

var myInterval = setInterval("updateInfo()", 3000);

Next, in your function, clear the interval when condition is matched:

> if (receiveReq.readyState == 4 && receiveReq.status == 200) {
>    document.getElementById('spanResult').innerHTML =
> receiveReq.responseText;

In that if, add the following:

clearInterval(myInterval);


and voila..you're done.



More information about the thelist mailing list