extjs获取不到json数据,大侠们帮忙看看
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: './json/aaaa.action'
}),
reader: new Ext.data.JsonReader(
{
totalProperty: 'total',
root: 'rows'},
[
{name: 'title'} ,
{name: 'context'},
{name: 'index_id', type:"int" } ]),
remoteSort:true
});
store.load();
alert(store.getCount());
控制台输出的数据是
{"total":2,"rows":[{"title":"学校概况","context":"帮忙你本命年科技","index_id":1},{"title":"校训详解","context":"个个 即可很快 看 ","index_id":2}]}
但store就是获取不到数据,不知道错在哪里了??
------解决方案--------------------在 load事件中输出看看
...
,listeners:{
load:function(){
alert(store.getCount());
}
}
------解决方案--------------------测下来没错, 只是中文的话,aaaa.action 返回页面的编码用UTF-8
JScript code
Ext.onReady(function(){
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'test.asp?' + escape(new Date())
}),
reader: new Ext.data.JsonReader(
{
totalProperty: 'total',
root: 'rows'},
[
{name: 'title'} ,
{name: 'context'},
{name: 'index_id', type:"int" }
]
),
listeners:{
load:function(){
alert(store.getCount());
}
}
});
store.load();
});
------解决方案--------------------
你试试看全英文的,可以的话,说明就是编码的问题了