Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Is this efficient?

I find myself doing this too often and it seems inefficient to me...

for example:

function testFunction(){
toggleSlide('addUsers');
document.getElementById(id).style.display = 'none';
getData('whatever.asp','container') // ajax call; page loads in div with id of container

/*the question I have is at this point - after an ajax call, specifically for loading a page. I usually find myself wanting to run another function or page call at this point. The problem is, since the previous page call is still in progress - it messes up the function and typically ignores one of the calls.

The way I've been working around that is setting a timeout for the second ajax page call or even function so that it waits a second or two for the prior call to finish */

setTimeout("getData('whateverTwo.asp','content')",1000);

}

That seems to work fine but just seems wrong.

Can anyone inform me of how to properly accomplish that - if it is indeed not the appropriate and,most importantly, efficient way of doing so?

Thank you for any help,

Israel
[1233 byte] By [israelnyc] at [2007-11-11 10:14:31]