Json 序列化和反序列化 Controllers 和View展示

Controllers:

        public ActionResult PrintTR06(string id)
        {
            List ListTR06 = new List();
          
            ListTR06.Add(new NARO.DAL.TRBase_06().GetDetail(id));

            //1:
            string strContent = JsonConvert.SerializeObject(ListTR06);
            //  return Content(strContent);

            //2:
            return Json(ListTR06, JsonRequestBehavior.AllowGet);
        }

View:

 $.ajax({
                    url: 'PrintTR06?id=' + rowData.RowGuid,
                    type: "post",
                    async: false,
                    success: function (result) {
                        
                        //1
                        //$(jQuery.parseJSON(result)).each(function (index, item) {
                        //   // alert(item.CE01);
                        //});

                        //2
                        $.each(result, function (i, item) {
                            alert(item.CE01);
                        });

                    },
                    error: function (err) {
                        alert(err.responseText);
                    }
                });

你可能感兴趣的:(Json 序列化和反序列化 Controllers 和View展示)