Ext.data.JsonStore发送请求并解析Json
Ext.onReady(function() {
var TabStore = new Ext.data.JsonStore({
proxy: {
type: 'ajax',
url: 'json/tab.json',
reader: {
type: 'json',
root: 'tab'
}
},
fields: ['name', 'url']
});
TabStore.load({
callback: function(records, operation, success) {
if (success) {
read();
} else {
alert("加载失败");
}
}
});
function read() {
for (var i = 0; i < TabStore.getCount(); i++) {
var TabData = TabStore.getAt(i);
console.log("name=" + TabData.get("name") + ",url=" + TabData.get("url"));
}
}
});
tab.json
{
"tab": [
{
"name": "人员管理",
"url": "html/page/pm.html"
}, {
"name": "资产管理",
"url": "html/page/page_2.html"
}
]
}