开发者

Mootools Request.JSON Decode

开发者 https://www.devze.com 2023-03-09 11:46 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消