JSFiddle - React, Tailwind, and code Playground
by mreis1
HTML
<a href="#">Click me!</a>
<div></div>
JavaScript
function GetSomeDeferredStuff() {
var deferreds = [];
var i = 1;
for (i = 1; i <= 10; i++) {
var count = i;
deferreds.push(
$.post('/echo/html/', {
html: "<p>Task #" + count + " complete.",
delay: count
}).success(function(data) {
$("div").append(data);
}));
}
return deferreds;
}
$(function() {
$("a").click(function() {
var deferreds = GetSomeDeferredStuff();
$.when.apply(null, deferreds).done(function() {
$("div").append("<p>All done!</p>");
});
});
});