motorhomer
New Coder
I have an ajax request returning an array. The array is ok to console log out as a hole but when i try to asses one part of the array I get a undefined
function
Result from console logging out complete array if I do
function
Code:
function reqIng() {
for (i = 0; i <= ing_len - 1; i++) {
$.when(ajaxCall2(ing_name[i])).done(function (ing_profile) {
var each_kcal = parseFloat(ing_profile[1]['kcal']);
kcal.push(each_kcal);
});
}
console.log(kcal[0]);
}
Code:
console.log(kcal)
Code:
[]
0: 0.4
1: 1.5
2: 0.3
3: 90
length 4
Array(0)