ext中读取json数据的问题

linger_liang linger_liang 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我开发的环境是.net2008的mvc框架+ext,我在服务期端的cs文件里将json数据生成,代码如下
public void GetCheck()
{
//db是已定义好的数据模块
var query = from a in db.SysUserAutTbl
select a;
int icount = query.Count();
var query1 = query.ToList();
string output = JsonConvert.SerializeObject(query1);
output = "{\"TotalRecord\":" + icount.ToString() + ",\"Data\":" + output + "}";
Response.Write(output);
}
output就是最后生成的json数据,如下
{"TotalRecord":3,"Data":[{"ID":1,"UserID":1,"MenuID":1,"QueryAut":"1","CreateAut":"1","UpdateAut":"1","DeleteAut":"1","PrintAut":"1","ApproveAut":"1","OtherAut1":"1","OtherAut2":"1","OtherAut3":"1","OtherAut4":"1","OtherAut5":"1","DiscretionAut":"1","SetAut":"1","ImportAut":"1","ExportAut":"1","ViewAut":"1","UploadAut":"1","DownloadAut":"1"},{"ID":2,"UserID":1,"MenuID":2,"QueryAut":"1","CreateAut":"1","UpdateAut":"1","DeleteAut":"1","PrintAut":"1","ApproveAut":"1","OtherAut1":"1","OtherAut2":"1","OtherAut3":"1","OtherAut4":"1","OtherAut5":"1","DiscretionAut":"1","SetAut":"1","ImportAut":"1","ExportAut":"1","ViewAut":"1","UploadAut":"1","DownloadAut":"1"},{"ID":3,"UserID":1,"MenuID":3,"QueryAut":"1","CreateAut":"1","UpdateAut":"1","DeleteAut":"1","PrintAut":"1","ApproveAut":"1","OtherAut1":"1","OtherAut2":"1","OtherAut3":"1","OtherAut4":"1","OtherAut5":"1","DiscretionAut":"1","SetAut":"1","ImportAut":"1","ExportAut":"1","ViewAut":"1","UploadAut":"1","DownloadAut":"1"}]}

然后我要在js里接收这个json数据,再对他进行遍历当有字段值为1我就进行一些操作,现在的问题是,我在js里怎么也接不过来数据,请大家帮忙看看,问题出在哪里,js接收json数据的代码如下:


var proxy = new Ext.data.HttpProxy({
url:'/UserMenuAut/GetCheck',
method:'GET'
});

var reader = new Ext.data.JsonReader(
{root:'Data',totalProperty :'TotalRecord'},
[
{name: 'ID'},
{name: 'UserID'},
{name: 'MenuID'},
{name: 'QueryAut'},
{name: 'CreateAut'},
{name: 'UpdateAut'},
{name: 'DeleteAut'},
{name: 'PrintAut'},
{name: 'ApproveAut'},
{name: 'OtherAut1'},
{name: 'OtherAut2'},
{name: 'OtherAut3'},
{name: 'OtherAut4'},
{name: 'OtherAut5'},
{name: 'DiscretionAut'},
{name: 'SetAut'},
{name: 'ImportAut'},
{name: 'ExportAut'},
{name: 'ViewAut'},
{name: 'UploadAut'},
{name: 'DownloadAut'}
]
);

var store = new Ext.data.Store(
{proxy:proxy,reader:reader}
);

store.load();
var licount=store.getCount();
});
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
linger_liang
Ajax 52,778 成员 25,334 内容