NOTE
This problem somehow happens only with a specific server-side api. Therefore it addresses the wrong problem. I'll not delete it since it have answers and comments.
I'm trying to execute a few ajax requests, do some stuff after each is done and some other stuff after all of them are done, for that I'm using the code below:
let
myarr = [],
myfunc = arg => myarr.push(arg);
$.when(
$.post(myparams).done(myfunc),
$.post(otherparams).done(myfunc),
$.post(yetanother).done(myfunc)
// it comes out with only one arg
).then(e => console.log(myarr));
But when it comes to execute the then
block it usually has only executed the done
of the first operation, how could I fix that?
I'm sorry if it's a duplicate but honestly I didn't even knew what to search for :/
Comment
I also tried to create my own deferreds where I would execute the ajax and resolve them inside the done
block, but that yielded the same results.
Using only done
or only then
, same.