I think you will need something like this:
var elementArray = yourAjaxRequestReturningSomethingEdibleByJQuery(); fadeInNextElement(elementArray); function fadeInNextElement(elementArray) { if (elementArray.length > 0) { var element = elementArray.pop(); $(element).fadeIn('normal', function() { fadeInNextElement(elementArray); } } }
Caution: I have not tested it, but even if it does not work, you should get this idea and easily fix it.
By the way, I do not agree with the use of a timer. With a timer, there is nothing to guarantee that the elements will disappear one by one, and the fading of one element will only begin if the previous one is finished.
Theoretically, it should work, but there may be times when your βchainβ should stop for some reason or the animation of fading cannot finish on time, etc. Just use the right chain.
Tamas Czinege Dec 19 '08 at 2:05 2008-12-19 02:05
source share