Skip to content Skip to sidebar Skip to footer

Problem With $.each() In JQuery

I want append some from array by jQuery.each and data hotel_id, number each hotel_id is 4, and this loop $.each(data[0].hotel_id,... }); run 4 times contents inside self, in case t

Solution 1:

You only have 3 elements in your residence_u and 2 in residence_p arrays, but 4 in the original hotels array. Could it be as simple as to check for a valid info_ru

var info_ru = data[0].residence_u[index];
if ( infor_ru != null ) {
    $.each(info_ru.units, function (index, value) {
        $tooltip.append(value + ' & ' + info_ru.extra[index] + ' & ' + info_ru.price[index] + '<br>');
    });
}

before continuing with the each?


Post a Comment for "Problem With $.each() In JQuery"