I have a problem and I don’t know how to resolve it. :-\
Here is my pseudo-code :
[AS]
my_loadvars = new LoadVars();
setInterval(“fct_1”, 10000, my_loadvars);
function fct_1(my_loadvars){
my_loadvars.load(“url”, POST);
}
my_loadvars.onload=function(){
“do some treatment with my_loadvars”
}
[/AS]
My problem is the following. I want to callback fct_1 10 seconds after my_loadvars.onload has been finished - not 10 seconds after setInterval has been called.
*Originally posted by Voglio * I want to callback fct_1 10 seconds after my_loadvars.onload has been finished - not 10 seconds after setInterval has been called.
Think about that… NOT 10 seconds after setInterval has been called… well, by definition of what setInterval IS, that will happen… but what if its CALLED in the onload? onload time == set interval call time == resulting fct_1 being run 10 seconds after onload time.
btw, the function should be defined before setInterval and be set without quotes (unless being run as a method in which case the object would need to be passed)
it wont be called AT the point you set the interval, only after that time has been passed, then the looping starts. though you can just as well do that yourself right afterwards.