I have made 4 ajax calls, it should return false (stop), when record 123456 is found. Also, record 123456 might exist in all four ajax results. However, instead of stop, the code continues to execute.
var endPoint0 = '';
var endPoint1 = '';
var endPoint2 = '';
var endPoint3 = '';
$.when(
$.ajax(endPoint0),
$.ajax(endPoint1),
$.ajax(endPoint2),
$.ajax(endPoint3)
).then(pass);
function pass(a, b, c, d){
var array = [];
array.push(a[0].guides, b[0].guides, c[0].guides, d[0].guides);
$.each(array, function(index,jsonObject){
$.each(jsonObject, function(i, item){
var e = item.program_id;
if (e == 123456) {
listing(item);
return false;
} else {
console.log('no record');
}
});
});
}
function listing () {
// display output here
}