My code is:
$(document).ready(function() {
var catArr=[];
$.get("viewData.php?action=getCat", function(json) {
if(json.catArr.length>0)
$.each(json.catArr, function()
{
catArr.push(this.category);
});
}, 'json');
$.each(catArr, function(index, el) {
console.log(el);
$("#category_selector").append($('<option>', {
value: el,
text : el
}));
});
});
I've ensured that the array catArr[] is filled by using console.log(). Here's a screenshot of that:
But I don't get any output due to console.log(el);
. Doesn't this mean that $.each() isn't executing? Why is that, and how do I fix it?