Zeitgeist Borders - Data Collection
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
function mkAllQueries(query) { | |
var allRes = {} | |
var promises = [] | |
for (var i = 0; i < nb_hls; i++){ | |
promises.push($.getJSON(apiUrl, { | |
"client": "firefox", | |
"hl": hls[i], | |
"q": query | |
}) | |
.done(function (hl, q) { | |
return function (data) { | |
allRes[hl] = data | |
} | |
}(hls[i], query, allRes)) | |
.fail(function (error) { | |
console.log(error) | |
}) | |
.always(function () { | |
console.log("Completed.") | |
}) | |
) | |
} | |
$.when.apply($, promises) | |
.done(function (data) { | |
allRes = formatRes(allRes) | |
doYourThing(allRes) | |
}) | |
.fail(function (error) { | |
console.log(error) | |
}) | |
.always(function () { | |
console.log("AllCompleted.") | |
}) | |
} | |
function doYourThing(allRes) { | |
console.log(allRes) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment