I need to make two async (Second call needs to be made only when some condition is true) calls and when both the calls returns data, I need to make another call. For this I decided to use jquery $when.
Before I make second Ajax call, I need to check some condition. And if its true, then I need to make second ajax call otherwise, there is no need to make second ajax call.
Here is Pseudo-code
$.when($.get(url, function (result, status, xhr) {
myresult = result;
})),
(
//If XYZ === 10
//Make second Ajax call only if condition is true
).then(function (r1, r2) {
//DO something
});
How can I achieve this ?? With Jquery or any other library ??