首页 > 代码库 > Json 序列化
Json 序列化
public ActionResult List(int oid, int pageIndex = DefaultPageIndex, int pageSize = Defaultpasesize) { OrdersOperator ordersOperator = new OrdersOperator(); var order = ordersOperator.Get(oid); if (order != null) { #region 其他车主对该租客的评论 long totalCount; long totalPageCount; var uid = CommonUserInfo.Uid; var dal = new EvaluationInfoViewOperator(); string where = string.Format("TargetUserId={0} and Verification>{1}", order.UserProfileId, 0); var list = dal.GetList(pageIndex, pageSize, out totalPageCount, out totalCount, where); string strResult = "{\"Status\":1" + ",\"totalCount\":" + totalCount + ",\"list\":" + JsonConvert.SerializeObject(list) + "}"; return Json(strResult, JsonRequestBehavior.AllowGet); #endregion } return View(); }
无刷新的调用该数据
//这个事件是在翻页时候用的 function pageselectCallback(pageId, jq) { //alert("pageId=" + pageId); CommentList(pageId); return false; } //得到评论列表 function CommentList(pageIndex) { $.post(‘/Evaluation/List‘, { oid: RequestName("orderId"), page: pageIndex }, function (data) { var strHtml = new StringBuilder(); data = eval("(" + data + ")"); //alert(data.totalCount); $("#commentNum").html(data.totalCount); console.dir(data); $.each(data.list, function(i, n) { strHtml.Append("<li>"); var userImgUrl = ‘/Content/Images/driver_image_empty‘; var filePath = ‘@Setting.FileServer‘; if (n.Avatar != ‘‘) { userImgUrl = filePath + "/" + n.Avatar; } strHtml.Append("<a href=http://www.mamicode.com/"\" class=\"pj_pic\"><img src=http://www.mamicode.com/"" + userImgUrl + "\" /></a><span>" + n.LoginId + "</span>"); strHtml.Append("<div class=\"pj_text\">"); strHtml.Append("<div class=\"pj_star\"></div>"); strHtml.Append("<div class=\"pj_neirong\">" + n.Content + "</div>"); strHtml.Append("<div class=\"pj_date\">评论时间:" + n.CreateTime.substring(0, 10) + "</div>"); strHtml.Append("</div>"); strHtml.Append("</li>"); }); $("#ulComment").html(strHtml.toString()); var objSelect = { callback: pageselectCallback, items_per_page: 15, //每页显示条目 //update firstPage、lastPage first_text: "首页", last_text: "末页", //update next_text: "下一页", num_display_entries: 5, num_edge_entries: 0, current_page: pageIndex, //当前页索引 prev_text: "上一页" }; $("#jPagination").pagination(data.totalCount, objSelect); if (data.totalCount > 10) { $("#jPagination").show(); } else { $("#jPagination").hide(); } }); }
Json 序列化
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。