jQuery Access Object Value -
hi guys can please show me how access content inside audiocollection object?
i using echonest jquery plugin jquery templates
https://github.com/rodeoclash/echonest-jquery-plugin/blob/master/scripts/echonest.js
i went on firebug , typed console.log(audiocollection)
, getting referenceerror: audiocollection not defined
. not sure if doing right.
echonest.artist(artist).audio( function(audiocollection) { $('#blog-page').find('.post').append( audiocollection.to_html('<p class="song-url" style="display:none;">${url}</p>') ); //appends url variable html inside of audiocollection var testing = audiocollection; //returns [object object] });
thank you!
i'm not familiar object, can try use dump()
function see what's in it..
echonest.artist(artist).audio( function(audiocollection) { $('#blog-page').find('.post').append( audiocollection.to_html('<p class="song-url" style="display:none;">${url}</p>') ); //appends url variable html inside of audiocollection var testing = audiocollection; //returns [object object] alert(dump(testing)); }); function dump(arr,level) { var dumped_text = ""; if(!level) level = 0; //the padding given @ beginning of line. var level_padding = ""; for(var j=0;j<level+1;j++) level_padding += " "; if(typeof(arr) == 'object') { //array/hashes/objects for(var item in arr) { var value = arr[item]; if(typeof(value) == 'object') { //if array, dumped_text += level_padding + "'" + item + "' ...\n"; dumped_text += dump(value,level+1); } else { dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n"; } } } else { //stings/chars/numbers etc. dumped_text = "===>"+arr+"<===("+typeof(arr)+")"; } return dumped_text; }
update
to access values, can this
var songs = testing.audio; (var x=0; x<songs.length; x++){ alert(songs[x].title); }
Comments
Post a Comment