码迷,mamicode.com
首页 > Web开发 > 详细

Json 序列化

时间:2014-11-17 15:43:55      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   color   ar   os   sp   for   数据   

       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();
                }
            });
        }

 

Json 序列化

标签:style   blog   io   color   ar   os   sp   for   数据   

原文地址:http://www.cnblogs.com/llxy/p/4103553.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!