views:

124

answers:

2

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 defently gets executed once ( at the end of the script), but the setTimeOut doesn't seem to work.

+1  A: 

Javascript is case sensitive- it should be setTimeout.
You also shouldn't use a string for the code part:

setTimeout(hol_logs, 10000);
Greg
thank you, it worked
Red33mer
+1  A: 

It's setTimeout. Also, wrap your call into function, like this:

setTimeout(function() { 
  hol_logs(); 
}, 10000);
emkee