JSFiddle - React, Tailwind, and code Playground
by marue
HTML
<div id="main"></div>
JavaScript
$('#main').html('somethin');
(function($) {
var ajaxQueue = $({});
$.ajaxQueue = function(ajaxOpts) {
var oldComplete = ajaxOpts.complete;
ajaxQueue.queue(function(next) {
ajaxOpts.complete = function() {
if (oldComplete) oldComplete.apply(this, arguments);
next();
};
$.ajax(ajaxOpts);
});
};
})(jQuery);
for (var i = 0; i < 3; i++) {
$.ajaxQueue({
url: '/echo/json/',
data: {
json: JSON.encode({
item_add: 'item' + i,
newindex: 'index' + i
})
},
type: 'GET',
success: function(data) {
$('#main').append(data['item_add']);
$('#main').append(data['newindex']);
}
});
};