Reputation: 369
I have an ajax method get who call my controller. Into success function it get two arrays: eventos.asignados
and eventos.noAsignados
Problem is validation always comes true, because it always send me alert, as you can see there:
can someone explain me why it pass validation if my array is not empty?
AJAX CALL:
$.ajax({
type: 'GET',
url: "/Agenda/GetTareasCalendario/",
data: {
//data there
},
dataType: 'json',
success: function (eventos) {
refreshCalendarEvents(eventos.asignados);
addEvents(eventos.noAsignados, true);
if ($.isEmptyObject(eventos.asignados && eventos.noAsignados)) {
alert('No se han encontrado resultados con los filtros seleccionados.');
}
}
});
});
Upvotes: 1
Views: 21
Reputation: 2588
Change your if
conditions like below to check for empty objects one by one
Try this:
if ($.isEmptyObject(eventos.asignados) && $.isEmptyObject(eventos.noAsignados)) {
alert('No se han encontrado resultados con los filtros seleccionados.');
}
Upvotes: 1