Last active
September 22, 2017 23:12
-
-
Save vielhuber/45ef4c40a08e25fa0ec7 to your computer and use it in GitHub Desktop.
synchronize two loads and execute function after both finished with Deferred #js
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
| var d1 = new $.Deferred(); | |
| var d2 = new $.Deferred(); | |
| $.when(d1, d2).then(function(r1, r2) { | |
| console.log(r1); | |
| console.log(r2); | |
| alert('done'); | |
| }); | |
| $.get(href1, function(data) { d1.resolve( data ); }) | |
| $.get(href2, function(data) { d2.resolve( data ); }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment