I have simple JS loop
jQuery('#checkbox-counter').live('click', function(){
jQuery.get('index.php?option=get_site_list=true',
function(data){
console.log(data[1]);
for(var index in data[1].id){
console.log(data[1].id[index]);
console.log(data[1].name[index]);
}
},
'JSON'
)
});
The problem is shown in the screen

It also prints some jquery code(in source) or shows functions in console… Where is the problem?
The
data[1].idanddata[1].nameproperties you are looping through are arrays, so you should use a conventionalforloop rather thanfor..in:When you use
for..init gives you other properties besides just the numerically indexed ones.