рони спешл фор ю:
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
var requestCounter = 0;
function fakeAjax(delay) {
var n = ++requestCounter;
var deferred = new $.Deferred();
setTimeout(function() {
$('body').append($('<div>', {text: 'Request ' + n + ' completed in ' + delay + ' ms. '}));
deferred.resolve();
}, delay);
return deferred;
}
var promises = [
fakeAjax(3000),
fakeAjax(500),
fakeAjax(1000),
];
$.when.apply($, promises).then(function() {
$('body').append($('<div>', {text: 'All requests completed'}));
});
</script>