JSFiddle - React, Tailwind, and code Playground
by bowheart
JavaScript
var dygraph_promises = []
for (var i = 0; i < 20; i++)
{
var plot_promise = $.ajax({
url : '/echo/json/',
type: 'POST',
data: {json : '{"test":"test"}', delay : 2}
})
plot_promise.done(function (a) {
console.log("DONE!");
// do stuff with data
});
// Keep track of promises
dygraph_promises.push(plot_promise);
}
// Synchronize dygraphs together
console.log(dygraph_promises);
console.log(dygraph_promises.length);
$.when.apply($, dygraph_promises)
.then(function () {
console.log("when called!");
});