JSFiddle - React, Tailwind, and code Playground
JavaScript
for (i = 0; i < 10; i++) {
(function (i) {
setTimeout(doAjax, (i * 500));
})(i);
}
function doAjax() {
$.ajax({
url: '/echo/html/',
type:'post',
beforeSend: function (xhr) {
xhr.start = new Date().getTime();
},
data: {
html: 'fooooo bar'
}
}).done(function (res, status, xhr) {
var end = new Date().getTime();
var elapsed = end - xhr.start;
$('body').append('<p>Elapsed =' + elapsed + ' (ms)</p>');
});
}