后台序列化Json数据,前台遍历循环到表格

这里只贴出前台代码。

        [WebMethod]
        public static string GetJsonData(string pid, string itemid)
        {
            string jsonstr = string.Empty;
            if (string.IsNullOrEmpty(pid) && string.IsNullOrEmpty(itemid))
            {
                //ShowOpResult("错误提示!", "");
            }
            else
            {
                List<Model.Enter_ProjectSeflChek_EX02_EXHistory> listdetails = BLLFactory<BLL.Enter_ProjectSeflChek_EX02_EXHistory>.Instance.GetEntityListAll("Leve", "ASC", "ProjectID = '" + pid + "' and ItemID = '" + itemid + "'");
                jsonstr = JsonConvert.SerializeObject(listdetails);
            }
            return jsonstr;
        }

 

前台获取并循环:

      function showDiv(itemid, pid) {
            $("#Layer10").show();
            $.ajax({
                type: "Post",
                url: "SeipProjectProCheck.aspx/GetJsonData",
                data: "{'pid':" + pid + ",'itemid':" + itemid + "}",
                contentType: "application/json;charset=utf-8",
                dataType: "json",
                success: function (jsonstr) {
                    var data = jsonstr.d;
                    var obj = eval("(" + data + ")");
                    
for (var i = 0; i < obj.length; i++) { $('#tb_detail').append("<tr><td>" + GetItemNameByID(obj[i].Ex02ID) + "</td><td>" + obj[i].Value + "</td><td>" + ChangeDateFormat(obj[i].Addtime) + "</td><tr>"); } }, error: function (xmlReq, err, c) { } }); }

 

你可能感兴趣的:(后台序列化Json数据,前台遍历循环到表格)