Jump to content

settimeout call multiple functions after a dealy not working?


sayedsohail

Recommended Posts

Hi everyone,

 

I am working on a settimeout function, where i can call functions in serialized form.

 

i.e, execute function 1 and after that execute 2 function .... so on.

 

here is my code, it just performing parallel way, i wish to perform in serial way.

 

var timer = null;
var delay = 500;
function startTimerGet(a)
{
window.clearTimeout(timer);

// function 1
timer=window.setTimeout('MyAjaxRequest()',delay);

// execute function 2 after completion of function 1 one or atleast after a small delay of function 1.

removeinner('titlegrid');

// execute function 3 after completion of function 2 one or atleast after a small delay of function 2.

refreshparentdiv();

}

i was able to worked it out in way, by adding function 2 next to function1, but this is not exactly i want i wish to send each function after a the set of delay.

 

timer=window.setTimeout('function1(); function2();',delay);

The other method,  am I close but somewhere lost?

 

var counter = 1;
function delayedCall(){
this["function"+counter++]();
if(counter<4){
	setTimeout("delayedCall()", 1000);
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.