Reputation: 1734
On a page having two ajax call inside the $.when method. I wanted to make a thrid ajax call based on page-level variable values.
$.when(
$.ajax({...}),
$.ajax({...}),
.done(function (a, b) {
........
});
Something like this?
$.when(
$.ajax({...}),
if(typeof myvalue != "undefined"){ // condition here ?
$.ajax({...}),
}
.done(function (a, b) {
........
});
Upvotes: 0
Views: 53
Reputation: 782785
Use a conditional expression:
$.when(
$.ajax({...}),
typeof myvalue != "undefined" ? $.ajax({...}) : null
).done(...)
Upvotes: 1