I am trying to use the timeout function within a jsp. But it doesn't work.
<script language="javascript">
function hol_logs() {
var myAjax = new Ajax.Request(
"getlogs.jsp",
{ method: 'get',parameters: 'jobId=<%=job%>', onComplete: zeige_logs }
);
setTimeOut("hol_logs()", 10000);
}
function zeige_logs( originalRequest ) {
$('output').innerHTML = originalRequest.responseText;
}
hol_logs();
</script>
As you can see, the function hol_logs
is supposed to be called every 10sec (I also tried it without the ()
, with no effect). It definitely gets executed once (at the end of the script), but the setTimeOut
doesn't seem to work.
Javascript is case sensitive- it should be setTimeout
.
You also shouldn't use a string for the code part:
setTimeout(hol_logs, 10000);
It's setTimeout
. Also, wrap your call into function, like this:
setTimeout(function() {
hol_logs();
}, 10000);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.