Saturday, 24 August 2013

Attempting to access property on JavaScript Object = Undefined

Attempting to access property on JavaScript Object = Undefined

I have this JavaScript object
Object {VoteTag: Object, ResortVoteTag: Array[1]}
ResortVoteTag: Array[1]
0: Object
id: "1"
resort_id: "1561"
tag_id: "4"
user_id: "31"
vote: "3"
length: 1
VoteTag: Object
id: "4"
tag: "Snowboarders"
type: "slopes"
I'm trying to access the vote property in the ResortVoteTag array however
I am unable to do so.
This is the following code I'm using.
$.ajax({
url: "/Votetags/alltags",
async: false,
dataType: 'json',
}).done(function ( data ) {
for(var i = 0; i < data.length; i++){
console.log(data[i].ResortVoteTag.id);
}
});

No comments:

Post a Comment