Skip to content

Instantly share code, notes, and snippets.

@vielhuber
Last active September 22, 2017 23:12
Show Gist options
  • Select an option

  • Save vielhuber/45ef4c40a08e25fa0ec7 to your computer and use it in GitHub Desktop.

Select an option

Save vielhuber/45ef4c40a08e25fa0ec7 to your computer and use it in GitHub Desktop.
synchronize two loads and execute function after both finished with Deferred #js
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