I'm trying to do a check via ajax various elements of an array. However, I am unable to run the loop correctly. can you help me?
https://jsfiddle.net/mzpsLvo6/
var codReferencia = ['1111','2222','3333','4444'];
$.each(codReferencia, function(index, val) {
$.ajax({
url: "https://webapi.toqueacampainha.com.br/api/estoque/produtoprontaentrega?refid=" + codReferencia,
dataType: 'json'
})
.done(function(data) {
if ( data >= '1' ) {
console.log('do anything');
} else {
console.log('do not do anything');
};
});
});