For example we've following code:
var data = [obj, obj, obj];
function handler(k, v) {
...
check(v, function() {});
}
function check(params, callback) {
...
request(options, callback);
}
function request(opts, callback) {
$.ajax({
...
opts
...
callback
});
}
$.each(data, handler);
How can we wait for done $.each and call some function? For example, something look like:
$.when($.each(data, handler)).then(alert(1));
I can not find solution.
P.S. We can not know length of data.
P.S. this is not duplicate because code apologize using promises or something pretty