I require an array to be structured in the following manner:
{"3":
{"label":"All i want for christmas",
"song":"Alliw_1405399165.mp3",
"name":"All i want for christmas"},
"4":
{"label":"Call your girlfriend robyn clip",
"song":"Gangnam_Style_2.m4a",
"name":"Call your girlfriend robyn},
"5":
{"label":"Gangnam style psy clip",
"song":"Samba_De_Janeiro-world_cup_for_jivebird.m4a",
"name":"Gangnam style psy clip"} }
These values are to be inserted after receiving an ajax response as shown below:
$.each(response.result, function(i,item){
label = item.name;
if((item.special_price < item.price)&&(item.special_price!=0) && (item.special_price!=null)) {
label += '- is Only '+ item.special_price + item.currencysymbol;
}
tmpsongList[item.product_id].push({'label': label,
'song': item.audiofile,
'name': item.name,
'tag': item.tag,
'song_path': item.audio_url});
});
However, this results in the error Uncaught TypeError: Cannot read property 'push' of undefined
How can I generate an array like this? Any assistance in resolving this issue would be greatly appreciated. Thank you.