我试图访问存储在数组中的每个对象的文本属性。该数组是另一个属性,结果,在一个对象内的值。如何访问javascript中其他对象内的对象内的属性
我使用jQuery从服务器检索对象,就像这样。
$.ajax({
url: "https://api.parse.com/1/classes/chats",
cache: false,
type: 'get',
async: false,
success: function(data){
console.log(data);
}
});
在最后的日志语句是看看我收到。自然,这是我需要做的事情,但我似乎无法破解代码。所以,我有一个结果属性和数组值的对象。该数组是一个对象数组,每个对象都有自己的属性。我只是有点困惑如何得到我需要的东西。也许轻轻推动正确的方向?
Object {results: Array[10]} //object returned
results: Array[10] //value is an array of objects
0: Object // object '0' expanded...
createdAt: "2013-10-15T19:13:43.576Z"<br><br>
objectId: "uzGerloXA7"
text: "RoboChat: I'm sorry Dave, I can't allow you to do that." // I need this!
updatedAt: "2013-10-15T19:13:43.576Z"
username: "RoboChat"
1:Object // and I need it for each of these objects.
2:Object
3:Object
etc...
9:Object //this is the last object.
我d建议使用像Firebug这样的工具,它可以让你设置断点和检查对象。这对学习和调试非常有用 – geedubb