JSFiddle - React, Tailwind, and code Playground
CSS
#test { font-size: xx-large; color: red; }
JavaScript
var $test = $('#test');
var queue = [];
function qNext() {
$.ajax(queue.shift()).success(qNext);
}
function qAjax(options) {
queue.push(options);
}
function callback(data) {
$test.append('<p>Returned data: ' + data + '</p>');
}
qAjax({
url: '/echo/json/',
type: 'POST',
data: {
json: '1',
delay: 2
},
success: callback
});
qAjax({
url: '/echo/json/',
type: 'POST',
data: {
json: '2',
delay: 3
},
success: callback
});
qAjax({
url: '/echo/json/',
type: 'POST',
data: {
json: '3',
delay: 1
},
success: callback
});
qNext();
// Example by http://stackoverflow.com/users/613198/rsp
// for http://stackoverflow.com/questions/5317535/