Created
February 19, 2014 03:06
-
-
Save athap/9085345 to your computer and use it in GitHub Desktop.
Wait for N or Multiple or Unknown number (Depends on some logic) of ajax request using JQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test | |
waitForTwoCalls: () -> | |
$.when(@firstCall(), @secondCall()).then () => | |
doSomeThing() | |
firstCall: () -> | |
token = $.Deferred | |
$.ajax({ | |
url: foo/bar, | |
.... | |
success: (response) => | |
token.resolve | |
}) | |
secondCall: () -> | |
token = $.Deferred | |
$.ajax({ | |
url: foo/bar, | |
.... | |
success: (response) => | |
token.resolve | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment