How do I execute jQuery / JavaScript code after query completed? (Using jQuery load with promises)
How do I execute jQuery / JavaScript code after query completed? (Using jQuery load with promises)
Just use example below for this and add to array so many constructions as you need
var def = [];
var res = [];
def.push(jQuery.get('/echo/jsonp', {key1: 'value1'}, function() {
res[0] = this.data + '<br/>';
}, 'jsonp'));
def.push(jQuery.get('/echo/jsonp', {key2: 'value2'}, function() {
res[1] = this.data + '<br/>';
}, 'jsonp'));
def.push(jQuery.get('/echo/jsonp', {key3: 'value3'}, function() {
res[2] = this.data + '<br/>';
}, 'jsonp'));
jQuery.when.apply(jQuery, def).done(function() {
jQuery('#container').append(res[0], res[1], res[2]);
});