Working with json from rails
Posted in Uncategorized on October 28th, 2009 by paul – Be the first to commentIf we have an array called users which contains a number of User objects sent from our rails app, then looping through this array gives us access to each user object.
for (var i = 0;i<users.length;i++) {
var user = users[i];
alert(user.user.name); //This gives us the name property of the object.
}
Note that each object in the array is preceeded by the name of the class, hence the double user. syntax.