KimhillZhang  

把省份与城市以树的形式输出

Ext.lib.Ajax.request(
       'POST',
       '/Index/mainIndex',
       { success: function (data) {
           data.responseText = "{pros:" + data.responseText + "}"; //获取后台回调的省份城市JSON格式数据
           var response = Ext.util.JSON.decode(data.responseText);
           var province = new Ext.XTemplate(
           '<tpl for="pros">',//遍历读取pros
           '<p>{id}--{text}</p>',
           '<tpl for="children">',//遍历读取pros下的children
               '<p style="margin-left:10px;">{id}--{text}</p>',
           '</tpl>',
           '</tpl>'
           );
           province.compile();
           province.append("Div2", response);
       }
       }
    );

posted on 2012-03-18 10:44  KimhillZhang  阅读(372)  评论(0编辑  收藏  举报