Mootools Request.JSON Decode
I am a beginner in mootools, can anyone help me figure out how to effectively decode each one of these shouts in JSON to log in the console.
var shoutsRequest = new Request.JSON(
{
url: this.url,
onSuccess: function(shouts)
{
开发者_运维知识库 console.log(JSON.decode(shouts));
},
onError: function(text, error)
{
console.log(text)
}
}
).get();
Here is the JSON.
[
{id:"1", username:"codyrob", shout:"This is a test.", time:"May 30, 3:20 pm"},
{id:"2", username:"codyrob", shout:"This is a test.", time:"May 30, 3:20 pm"},
{id:"3", username:"codyrob", shout:"This is a test.", time:"May 30, 3:20 pm"},
{id:"4", username:"codyrob", shout:"This is a test.", time:"May 30, 3:20 pm"},
{id:"5", username:"codyrob", shout:"This is a test.", time:"May 30, 3:20 pm}
]
looks like an array containing objects [{}, {}, {}] so you could iterate over the array
http://jsfiddle.net/3qnJ2/
http://mootools.net/docs/core/Types/Array#Array:Array-each
精彩评论