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=\"\" class=\"pj_pic\"><img src=\"" + 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(); } }); }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。