jQuery: How to fire event when all asynchronous calls return?
        Posted  
        
            by Jeremy
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Jeremy
        
        
        
        Published on 2010-05-28T00:35:15Z
        Indexed on 
            2010/05/28
            0:41 UTC
        
        
        Read the original article
        Hit count: 337
        
I have a jQuery application that loads data from five asynchronous server calls. I do not want to display any data until all five calls return. (I plan on displaying a Loading message until that happens.)
How can I detect when all five calls have returned? I considered having each callback method increment a variable (using jQuery's data() method, perhaps) and then waiting for the value to become 5. (I am not sure yet how I would listen for that event.) I do not think this is a very good solution, however. What would happen if two calls return at the same time?
Is there a better way to do this?
© Stack Overflow or respective owner