I'm really trying hard to understand the behavior or JQuery's promise().
I want to do 3 (unrelated, but back-to-back) AJAX queries :
1. GET the user data
2. POST an image
3. POST another image
Then, I'm doing a load of things that are based on then results of said queries.
Now, the $.when(ajax, ajax, ajax).then(userData, img1, img2) functions work great for this as of now, but what if I want my ajax calls to be wrapped around conditions, as so :
$.when(
if(...){
$.ajax({ ...GET user data... });
}
if(...){
$.ajax({ ...POST image... });
}
if(...){
$.ajax({ ...POST image... });
}
).then(function(userData, img1, img2){
if(img1){
...do something with img1...
}
...same for other responses...
});
I'm aware that my code doesn't contain any promise, but really, everything I've tried failed pretty badly in this scenario.
Any hint/tip appreciated. Thanks.