日期:2014-05-17  浏览次数:20503 次

json数据处理
function xmfile(month, num, FBillID) {
            $.ajax({
                type: "get",
                dataType: "json",
                url: "/Services/File.ashx?month=" + month + "&num=" + num + "&FBillID=" + FBillID + "",
                success: function (data) {
                    alert(data);
                    alert(data[0].Fid);
                }
            });
        };

这是File.ashx页面获取的数据:{"shuju":[{"Fid":"1","FBillid":"4","FYear":"2013","FMonth":"1","FOrder":"","FAnnexName":"xerces.dll","FAnnexPath":"UploadFiles//测试1/2013/6/2013061810430387.dll","FDate":""},{"Fid":"3","FBillid":"4","FYear":"2013","FMonth":"1","FOrder":"1","FAnnexName":"jxConstMS.vssscc","FAnnexPath":"UploadFiles//测试1/2013/6/2013061811144968.vssscc","FDate":"2013-6-18 11:14:49"}]}

弹出[object Object]
data[0].Fid 不存在
数据还要如何处理,错误在哪里?
JSON

------解决方案--------------------
var dataObj = eval(data); 
alert(dataObj[0].Fid);

试试。
------解决方案--------------------
不喜欢这样的方式
url: "/Services/File.ashx?month=" + month + "&num=" + num + "&FBillID=" + FBillID + "",
很容易拼接错误
试试
data:{Month:month}
http://jun1986.iteye.com/blog/1399242
------解决方案--------------------
请看下图你json的结构。


应该是 data.shuju[0].Fid
------解决方案--------------------
你在File.ashx 里直接定义的:string data="{"shuju":[{"Fid":"1","FBillid":"4","FYear":"2013","FMonth":"1","FOrder":"","FAnnexName":"xerces.dll","FAnnexPath":"UploadFiles//测试1/2013/6/2013061810430387.dll","FDate":""},{"Fid":"3","FBillid":"4","FYear":"2013","FMonth":"1","FOrder":"1","FAnnexName":"jxConstMS.vssscc","FAnnexPath":"UploadFiles//测试1/2013/6/2013061811144968.vssscc","FDate":"2013-6-18 11:14:49"}]}"; 吗?
还是用JavaScriptSerializer serializer = new JavaScriptSerializer();
序列化后得到的数据呢? 直接定义的好像也没取的时候还的反序列化!要是用JavaScriptSerializer 的话也没就不用反序列化了!