首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

jquery 简单的绑定有关问题,

2012-12-31 
jquery 简单的绑定问题,急!!!在线等有一json数据如下:var json{d:[{__type:KH.FMCG.Model.Pro_Visi

jquery 简单的绑定问题,急!!!在线等





有一json数据如下:
var json="

{"d":[{"__type":"KH.FMCG.Model.Pro_VisitPlan","VisitPlanId":3,"VisitPlanCode":"PL000020121219165059","ProjectId":1,"ShopId":6,"VisitDate":"/Date(1354377600000)/","EnterTime":"01:10","LeaveTime":"02:20","ApprovalState":0,"ExecuteState":0,"IsCollectSales":true,"IsCollectStock":false,"IsCollectSurvey":true,"Remark":"dtdfgdf","CreateUser":1,"CreateDate":"/Date(-62135596800000)/","UpdateUser":0,"UpdateDate":"/Date(-62135596800000)/","Valid":0}]}

"
将以上json数据中的VisitPlanId ,VisitPlanCode,Remark 三个字段的值绑定出来
$.each(json, function (i) {
              $("#demo").append("<a id='a" + VisitPlanId + "'>" + Remark + "</a>");
     });




请各位大神帮帮忙啊
[解决办法]
var dataObj=eval("("+json+")");


在你代码里面加上这句  再去 each dataObj
[解决办法]
切记,理清JSON结构
var json = '{"d":[{"__type":"KH.FMCG.Model.Pro_VisitPlan","VisitPlanId":3,"VisitPlanCode":"PL000020121219165059","ProjectId":1,"ShopId":6,"VisitDate":"/Date(1354377600000)/","EnterTime":"01:10","LeaveTime":"02:20","ApprovalState":0,"ExecuteState":0,"IsCollectSales":true,"IsCollectStock":false,"IsCollectSurvey":true,"Remark":"dtdfgdf","CreateUser":1,"CreateDate":"/Date(-62135596800000)/","UpdateUser":0,"UpdateDate":"/Date(-62135596800000)/","Valid":0}]}';
            var data = eval('(' + json + ')');
            $.each(data, function (i) {
                $.each(data.d, function (j) {
                    $("#demo").append("<a id='a" + this.VisitPlanId + "'>" + this.Remark + "</a>");
                });
            });

热点排行