Created
June 29, 2009 20:56
-
-
Save paul/137804 to your computer and use it in GitHub Desktop.
This file contains 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 results = {}; | |
var requests = 0; | |
var urls = ["values/1", "values/2", "values/3"]; | |
$.each(urls, function(url) { | |
$.getJSON(url, function(data) { | |
results[url] = data.value; | |
++requests; | |
if (requests == 3) { | |
$('#mynode').html( results[urls[0]] / results[urls[1]] * results[urls[2]]); | |
} | |
}); | |
}); | |
This file contains 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
$.getJSON("/values/1", function(data) { | |
// data = {value: 1} | |
var value_1 = data.value; | |
$.getJSON("/values/2", function(data) { | |
// data = {value: 42} | |
var value_2 = data.value; | |
var sum = value_1 + value_2; | |
$('#mynode').html(sum); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error in line 6 of parallel.js, see forked copy at https://gist.github.com/jamiesonbecker/5077534 for fix.