I get the following back from an $.ajax({ POST.....
[{"total_votes":1,"options":[{"id":40,"vote_count":0,"users":[]},{"id":41,"vote_count":1,"users":[{"photo":"xxxxxxxxxxx.png","name":"XXXXX,"id":1}]},{"id":42,"vote_count":0,"users":[]}]}]
so I try to get total_votes with:
success: function(e) {
console.log(e['total_votes'])
}
also try to get
console.log( e['options'].length() )
console.log( e['options'][0]['id'] )
Suggestions on why I keep getting undefined? Also is there a better way to loop through options?
Thanks
$.ajax()method. Did you set thedataType:property to'json'? If not, is it being sent from the server with the proper headers?