JSFiddle - React, Tailwind, and code Playground

by gRoberts

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js"></script>

JavaScript

function ajaxUpdate(x, y) {
	return $.ajax({
    url: '/echo/html/',
    data: 'version='
  });
}

var deferred = [],
	versions = [1,2,3,4,5,6];
$.each(versions, function(key, value) {
	console.log('Doing: %s', value);
  deferred.push(
    ajaxUpdate('download',value).then(function() {
    	console.log('Hitting: %s', value);
    })
  );
});
$.when.apply($, deferred).done(function() {
    // complete
    alert('all done');
});