3个不难易行的Ext.XTemplate例子

把省份与城市以树的花样出口

Ext.lib.Ajax.request(
       ‘POST’,
       ‘/Index/mainIndex’,
       { success: function (data) {
           data.responseText = “{pros:” + data.responseText + “}”;
//获取后台回调的省区都会JSON格式数据
           var response = Ext.util.JSON.decode(data.responseText);
Ajax,           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);
       }
       }
    );

Ajax 1

相关文章