On 11 sep, 06:23, ned <[EMAIL PROTECTED]> wrote:
> Hi to everybody,
> I want to explain you "my little problem".
> I have something like this:
>
> $("#newsticker").load("file.php");
>
> This code is very simple and works well, but now I want to repeat the
> file's load every 30 seconds until a timeout of 2000 seconds. How can
> I realize this?

Here are two methods, supposing you don't care how long it takes for
the .load(): (the syntax needs to be checked)

var count = 0;

function myload() {
      $("#newsticker").empty().load("file.php");
      if (count++ < 66) setTimeout(myload, 30000);
}

$(document).ready(function() { myload(); });

... and if you really want to stop it after exactly 2000 seconds, you
could do:

var t;
function myload() { $("#newsticker").empty().load("file.php"); t =
setTimeout(myload, 30000); }
$(document.read(function() { myload(); setTimeout(function()
{ clearTimeout(count); console.log('cleared');}, 2000000); });

Regards,
Renaud Drousies







> Thank you, bye
>
> Gabriele

Reply via email to