theoretically something like function updateTimer(object_id) { $.get("checkchanges.php",{object_id:object_id}, function(msg) { $("#timer"+object_id).append(msg); setTimeout("updateTimer("+object_id+")", 1000); }); }
is what you're looking for just carry on execution in the callback. there are a lot of other ways to write this, depending on the feeling you're going for. On Mar 30, 8:41 am, unska <[EMAIL PROTECTED]> wrote: > Hey.. I'm having some problems to put the data from the load() > function to a variable. I'm currently using the code below but I need > some modifications to it. > > function updateTimer(object_id) { > $("#timer"+object_id).load("checkchanges.php?object_id="+object_id); > setTimeout("updateTimer("+object_id+")", 1000); > > } > > As you see it puts the checkchanges.php's data to the span called > timerX but I want to put the same data to a variable, how can I do > this? Someone already suggested me to do it like this: > > $.ajax({ > type: "GET", > url: "checkchanges.php?object_id="+object_id, > success: function(msg){ > variablex=msg; > } > }); > > But that's useless, because the variablex is stuck inside the unnamed > function and therefore useless.