your code as posted will call force_shout_update once at page load
that will wait 1 second before sending off single ajax request
this behavior does not do any constant refreshing
function force_shout_update() {
setTimeout("sndReq('go')",1000);
}
window.onload=force_shout_update();
your note show you konw how to get a result more like you asked for with the setInterval function
function force_shout_update() {
setTimeout("sndReq('go')",5000);
}
window.setInterval("force_shout_update()",1000);
however, this will call force_shout_update every second and each force_shout_update will wait 5 seconds and call sendRed, which will really just be calling it every second
sec 1 : force_shout_update_1
sec 2 : force_shout_update_2
sec 3 : force_shout_update_3
sec 4 : force_shout_update_4
sec 5 : force_shout_update_5
sec 6 : force_shout_update_6, sendReq_1
sec 7 : force_shout_update_7, sendReq_2
sec 8 : force_shout_update_8, sendReq_3
sec 9 : force_shout_update_9, sendReq_4
sec 10 : force_shout_update_10, sendReq_5
i believe you want your code to look something like this
var _shout_interval = null
function start_shout_updates( interval_in_seconds )
{
stop_shout_updates();
_shout_interval = setInterval("force_shout_update()", interval_in_seconds * 1000 );
}
function stop_shout_updates()
{
clearInterval(_shout_interval);
}
function force_shout_update() {
sndReq('go');
}
window.onload = start_shout_updates