JSFiddle - React, Tailwind, and code Playground

HTML

<div id="foo" class="res"></div>
<div id="bar" class="res"></div>
<div id="baz" class="res"></div>
<div id="foobar" class="res"></div>
<div id="foobazbar" class="res"></div>
<div id="refresh"></div>

JavaScript

var refresh = function() {
    $('#refresh').text('REFRESH - ' + (new Date).getTime().toString());
}

$(function() {

    var $res = $('.res'),
        $promises = [];

    $res.each(function(id) {
        var $this = $(this);

        $promises.push(
            $.post("/echo/json/", {
                'json': JSON.stringify({'id': $this.attr('id')})
            }, function(data, status, xhr) {
                $this.text('success ' + data.id + ' - ' + (new Date).getTime().toString());
            })
        );
    });

    $.when.apply($, $promises).then(function() {
        refresh();
    });

});