1

I have an ajax function as follows:-

$.ajax({
    type: "GET",
    dataType: "json",
    async: false,
    url: "/wp-content/comment_data.php",
    data: 'songid=' + $array,
    success: function(data){
        oTable.find('td').each(function(){
            $id = $(this).data('songid');
            songid = 'songid-' + $id;
            $commentbar = $(this).find('#comment-bar' + $id);
            array = data.songid;

            $.tmpl( "commentBarTemplate", array ).appendTo($commentbar);
        });     
    }
}); 

What this does is collects a list of id's on the page (the songid of each 'td'), sends the array to my server side script where everything is processed and a JSON response containing comments/replies is returned for each songid. Ass you can see each array of comments/replies is stored in the array under 'songid-24', 'songid-23' etc...

My PHP script returns the following JSON:

{ "songid-22" : [  ],
  "songid-23" : [ { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "test",
        "display_name" : "admin",
        "id" : "5",
        "playtime" : "56",
        "posttime" : "2011-09-28 15:32:41",
        "songid" : "23",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "test comment",
        "display_name" : "admin",
        "id" : "6",
        "playtime" : "87",
        "posttime" : "2011-09-28 16:38:37",
        "songid" : "23",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      }
    ],
  "songid-24" : [ { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "comment at 0:48",
        "display_name" : "admin",
        "id" : "2",
        "playtime" : "48",
        "posttime" : "2011-09-28 14:38:41",
        "replies" : [ { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
              "body" : "haha reply",
              "cid" : "2",
              "display_name" : "admin",
              "id" : "1",
              "posttime" : "2011-09-28 15:14:56",
              "uid" : "1",
              "user_login" : "admin",
              "user_url" : "http://www.songbanc.com/members/admin/"
            },
            { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
              "body" : "next replty",
              "cid" : "2",
              "display_name" : "admin",
              "id" : "2",
              "posttime" : "2011-09-28 15:15:07",
              "uid" : "1",
              "user_login" : "admin",
              "user_url" : "http://www.songbanc.com/members/admin/"
            },
            { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
              "body" : "first reply",
              "cid" : "2",
              "display_name" : "admin",
              "id" : "3",
              "posttime" : "2011-09-28 15:15:15",
              "uid" : "1",
              "user_login" : "admin",
              "user_url" : "http://www.songbanc.com/members/admin/"
            }
          ],
        "songid" : "24",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "asdasd",
        "display_name" : "admin",
        "id" : "3",
        "playtime" : "2",
        "posttime" : "2011-09-28 14:43:11",
        "replies" : [ { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
              "body" : "test reply",
              "cid" : "3",
              "display_name" : "admin",
              "id" : "5",
              "posttime" : "2011-10-06 14:35:23",
              "uid" : "1",
              "user_login" : "admin",
              "user_url" : "http://www.songbanc.com/members/admin/"
            },
            { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
              "body" : "test reply",
              "cid" : "3",
              "display_name" : "admin",
              "id" : "6",
              "posttime" : "2011-10-07 14:48:21",
              "uid" : "1",
              "user_login" : "admin",
              "user_url" : "http://www.songbanc.com/members/admin/"
            }
          ],
        "songid" : "24",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "test",
        "display_name" : "admin",
        "id" : "10",
        "playtime" : "97",
        "posttime" : "2011-10-06 14:15:12",
        "songid" : "24",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      }
    ],
  "songid-25" : [  ],
  "songid-26" : [  ],
  "songid-27" : [  ],
  "songid-28" : [  ],
  "songid-29" : [ { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "hello hello!",
        "display_name" : "admin",
        "id" : "24",
        "playtime" : "55",
        "posttime" : "2011-10-08 10:54:37",
        "replies" : [ { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
              "body" : "further testing!",
              "cid" : "24",
              "display_name" : "admin",
              "id" : "12",
              "posttime" : "2011-10-08 10:54:48",
              "uid" : "1",
              "user_login" : "admin",
              "user_url" : "http://www.songbanc.com/members/admin/"
            },
            { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/3/47459545ffdbdfffa7620ce562e44c54-bpthumb.jpg",
              "body" : "test reply",
              "cid" : "24",
              "display_name" : "test user 2",
              "id" : "13",
              "posttime" : "2011-10-08 11:12:42",
              "uid" : "3",
              "user_login" : "testing",
              "user_url" : "http://www.songbanc.com/members/testing/"
            }
          ],
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "Awesome!",
        "display_name" : "admin",
        "id" : "25",
        "playtime" : "135",
        "posttime" : "2011-10-08 10:54:58",
        "replies" : [ { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/3/47459545ffdbdfffa7620ce562e44c54-bpthumb.jpg",
              "body" : "geggegge",
              "cid" : "25",
              "display_name" : "test user 2",
              "id" : "16",
              "posttime" : "2011-10-24 20:04:33",
              "uid" : "3",
              "user_login" : "testing",
              "user_url" : "http://www.songbanc.com/members/testing/"
            } ],
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/3/47459545ffdbdfffa7620ce562e44c54-bpthumb.jpg",
        "body" : "testing...",
        "display_name" : "test user 2",
        "id" : "27",
        "playtime" : "35",
        "posttime" : "2011-10-08 11:13:01",
        "replies" : [ { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
              "body" : "grgrgehhehehe",
              "cid" : "27",
              "display_name" : "admin",
              "id" : "14",
              "posttime" : "2011-10-11 15:22:02",
              "uid" : "1",
              "user_login" : "admin",
              "user_url" : "http://www.songbanc.com/members/admin/"
            },
            { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
              "body" : "testing",
              "cid" : "27",
              "display_name" : "admin",
              "id" : "15",
              "posttime" : "2011-10-11 18:23:01",
              "uid" : "1",
              "user_login" : "admin",
              "user_url" : "http://www.songbanc.com/members/admin/"
            },
            { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
              "body" : "another",
              "cid" : "27",
              "display_name" : "admin",
              "id" : "20",
              "posttime" : "2011-11-25 14:52:02",
              "uid" : "1",
              "user_login" : "admin",
              "user_url" : "http://www.songbanc.com/members/admin/"
            }
          ],
        "songid" : "29",
        "uid" : "3",
        "user_login" : "testing",
        "user_url" : "http://www.songbanc.com/members/testing/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "Just testing out the commenting functionality and seeing how good it is now that i\\'ve modified the styling etc...",
        "display_name" : "admin",
        "id" : "29",
        "playtime" : "80",
        "posttime" : "2011-10-11 00:46:58",
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "hfhhghfhhhhshfdhsh",
        "display_name" : "admin",
        "id" : "30",
        "playtime" : "110",
        "posttime" : "2011-10-11 15:21:42",
        "replies" : [ { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
              "body" : "thrthhrht",
              "cid" : "30",
              "display_name" : "admin",
              "id" : "19",
              "posttime" : "2011-11-10 14:19:03",
              "uid" : "1",
              "user_login" : "admin",
              "user_url" : "http://www.songbanc.com/members/admin/"
            } ],
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "testing......",
        "display_name" : "admin",
        "id" : "31",
        "playtime" : "154",
        "posttime" : "2011-10-13 02:10:42",
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "hello",
        "display_name" : "admin",
        "id" : "32",
        "playtime" : "94",
        "posttime" : "2011-10-13 02:12:27",
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "blah",
        "display_name" : "admin",
        "id" : "33",
        "playtime" : "121",
        "posttime" : "2011-10-13 02:16:25",
        "replies" : [ { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/3/47459545ffdbdfffa7620ce562e44c54-bpthumb.jpg",
              "body" : "eeffefef",
              "cid" : "33",
              "display_name" : "test user 2",
              "id" : "17",
              "posttime" : "2011-10-24 20:04:48",
              "uid" : "3",
              "user_login" : "testing",
              "user_url" : "http://www.songbanc.com/members/testing/"
            } ],
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "comment",
        "display_name" : "admin",
        "id" : "34",
        "playtime" : "70",
        "posttime" : "2011-10-13 02:17:54",
        "replies" : [ { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/3/47459545ffdbdfffa7620ce562e44c54-bpthumb.jpg",
              "body" : "feffefee",
              "cid" : "34",
              "display_name" : "test user 2",
              "id" : "18",
              "posttime" : "2011-10-24 20:04:56",
              "uid" : "3",
              "user_login" : "testing",
              "user_url" : "http://www.songbanc.com/members/testing/"
            } ],
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "commenting",
        "display_name" : "admin",
        "id" : "35",
        "playtime" : "20",
        "posttime" : "2011-10-13 02:20:31",
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "ffgwgwgwgwgw",
        "display_name" : "admin",
        "id" : "36",
        "playtime" : "102",
        "posttime" : "2011-10-13 02:21:30",
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/3/47459545ffdbdfffa7620ce562e44c54-bpthumb.jpg",
        "body" : "this is a test comment to see if avatars work",
        "display_name" : "test user 2",
        "id" : "64",
        "playtime" : "62",
        "posttime" : "2011-10-13 11:46:45",
        "songid" : "29",
        "uid" : "3",
        "user_login" : "testing",
        "user_url" : "http://www.songbanc.com/members/testing/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/3/47459545ffdbdfffa7620ce562e44c54-bpthumb.jpg",
        "body" : "comment",
        "display_name" : "test user 2",
        "id" : "65",
        "playtime" : "170",
        "posttime" : "2011-10-13 12:21:51",
        "songid" : "29",
        "uid" : "3",
        "user_login" : "testing",
        "user_url" : "http://www.songbanc.com/members/testing/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/3/47459545ffdbdfffa7620ce562e44c54-bpthumb.jpg",
        "body" : "rtrgrrg",
        "display_name" : "test user 2",
        "id" : "66",
        "playtime" : "44",
        "posttime" : "2011-10-13 13:01:37",
        "songid" : "29",
        "uid" : "3",
        "user_login" : "testing",
        "user_url" : "http://www.songbanc.com/members/testing/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/3/47459545ffdbdfffa7620ce562e44c54-bpthumb.jpg",
        "body" : "hello world",
        "display_name" : "test user 2",
        "id" : "67",
        "playtime" : "178",
        "posttime" : "2011-10-13 13:44:17",
        "songid" : "29",
        "uid" : "3",
        "user_login" : "testing",
        "user_url" : "http://www.songbanc.com/members/testing/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "comment time!!! YAY!!",
        "display_name" : "admin",
        "id" : "68",
        "playtime" : "48",
        "posttime" : "2011-10-13 15:07:56",
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "hello world...",
        "display_name" : "admin",
        "id" : "72",
        "playtime" : "86",
        "posttime" : "2011-10-13 17:18:58",
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "ygygyigyiugyugyuig",
        "display_name" : "admin",
        "id" : "73",
        "playtime" : "28",
        "posttime" : "2011-10-14 11:07:27",
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "test\n",
        "display_name" : "admin",
        "id" : "74",
        "playtime" : "146",
        "posttime" : "2011-10-24 19:40:36",
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/3/47459545ffdbdfffa7620ce562e44c54-bpthumb.jpg",
        "body" : "htththth",
        "display_name" : "test user 2",
        "id" : "76",
        "playtime" : "197",
        "posttime" : "2011-10-24 20:05:47",
        "songid" : "29",
        "uid" : "3",
        "user_login" : "testing",
        "user_url" : "http://www.songbanc.com/members/testing/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "fdgrttgrhrgrgrt",
        "display_name" : "admin",
        "id" : "77",
        "playtime" : "131",
        "posttime" : "2011-11-10 14:18:12",
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "hello",
        "display_name" : "admin",
        "id" : "78",
        "playtime" : "190",
        "posttime" : "2011-11-10 14:18:52",
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "testing",
        "display_name" : "admin",
        "id" : "79",
        "playtime" : "117",
        "posttime" : "2011-11-17 08:50:38",
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "hfdhfdhfdhdhfhhfdh",
        "display_name" : "admin",
        "id" : "80",
        "playtime" : "74",
        "posttime" : "2011-11-18 17:29:39",
        "songid" : "29",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      }
    ],
  "songid-30" : [ { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "More tests....",
        "display_name" : "admin",
        "id" : "26",
        "playtime" : "126",
        "posttime" : "2011-10-08 11:11:55",
        "songid" : "30",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "I\\'m just testing the automatic slash  stripper \\\"hello\\\", \\'yay\\' !!! it works!!",
        "display_name" : "admin",
        "id" : "70",
        "playtime" : "103",
        "posttime" : "2011-10-13 15:51:01",
        "songid" : "30",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      },
      { "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
        "body" : "Another genius comment....",
        "display_name" : "admin",
        "id" : "71",
        "playtime" : "170",
        "posttime" : "2011-10-13 15:55:38",
        "songid" : "30",
        "uid" : "1",
        "user_login" : "admin",
        "user_url" : "http://www.songbanc.com/members/admin/"
      }
    ]
}

What I am trying to do once I have recieved the JSON response, is then iterate back through each 'td' and append a jQuery template to each one.

The problem is that I need to dynamically select the data key i.e data.songid-24, data.songid-23 etc.

Within the each loop I am able to collect the id itself as shown in the code as $id as I have it stored on each 'td' by using the jquery.data method.

Any ideas?

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
gordyr
  • 6,078
  • 14
  • 65
  • 123

3 Answers3

0

Change array = data.songid to:

array = data[songid];
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
0

I just managed to solve it myself... It turns out that using a '-' in the song id's was confusing it somehow. Removing this and using songid24, songid23 etc... in my JSON fixed it instantly.

Many thanks for the suggestions regardless.

gordyr
  • 6,078
  • 14
  • 65
  • 123
0

I think you are not using the $.tmpl() as it should be. Please first read the doc carefully.

Then try changing your json to smthing like this.

[ {},
 { 
    "avatar" : "http://www.songbanc.com/wp-content/uploads/avatars/1/8bb11e958a26913e2c13393014e854d5-bpthumb.jpg",
    "body" : "test",
    "display_name" : "admin",
    "id" : "5",
    "playtime" : "56",
    "posttime" : "2011-09-28 15:32:41",
    "songid" : "23",
    "uid" : "1",
    "user_login" : "admin",
    "user_url" : "http://www.songbanc.com/members/admin/"
  },
  {....},
  etc ....

You can easily change this with a for loop either server side or client side.

Your template should be smthing like this

var markup = "<li><b>${avatar}</b> (${body}) etc...</li>";
// Compile the markup as a named template
$.template( "commentBarTemplate", markup );

(The html code in the template is just an example)

alex
  • 580
  • 1
  • 4
  • 12
  • Thanks alex, that was originally how I had the templates set, however I now need further layers of nested information all in one get request. If I did as you suggested I would require 10 seperate get request to retrieve the comments/replies for 10 songs. Doing it the way I am now means one single GET request. Everything works beautifully now and I have reduced server load while optimizing the template rendering. – gordyr Jan 10 '12 at 11:36
  • Yes , you dont need to make 10 get request. Glad you found it. – alex Jan 10 '12 at 11:48