zoukankan      html  css  js  c++  java
  • json全套

    JS文件

    function pager1_InitData() {
        //基础配置
        $("#pager1").myPagination({
            currPage: 1,
            pageCount: 1,
            pageSize: 10,
            cssStyle: 'quotes',
            info: {
                cookie_currPage: true, //开启 Coookie保存页数模式
                cookie_currPageKey: "pager1_H"	//保存 cookie 值为 demo1_currPage
            },
            ajax: {
                on: true,                        //开启状态
                callback: 'pager1call',    //回调函数
                url: "/AJAXFUNC/OrderHandler.ashx",            //访问服务器地址
                dataType: 'json',                //返回类型
                param: { on: true, type: '2', ispaid: 'null', payway: '0', bdate: $("[id$='all_beginDate']").val(), edate: $("[id$='all_endDate']").val(), name: $("[id$='all_ticketName']").val() },
                pageContId: "pageCount"
            }
        });
    }

    JS文件中的回调函数

    function pager1call(data) {
        var orderInfo = data;
        $("#all_TicketOrder").html("");
        var html = "";
        for (var i = 0; ; i++) {
            if (orderInfo.listPo[i] == undefined) {
                break;
            }
            else {
                html += "<tr>";
                html += "<td width='70' height='35' class='xian'>";
                html += "" + orderInfo.listPo[i].orderid + "</td>";
                html += "<td width='120' class='xian'>";
                html += orderInfo.listPo[i].upname + "</td>";
                html += "<td width='110' class='xian'>";
                html += "" + orderInfo.listPo[i].createtime + "</td>";
                html += "<td width='130' class='xian'>";
                html += "" + orderInfo.listPo[i].name + "</td>";
                html += "<td width='100' class='xian'>";
                html += "" + orderInfo.listPo[i].endtime + "</td>";
                html += "<td width='80' class='xian'>";
                html += "" + orderInfo.listPo[i].totalmoney + "</td>";
                html += "<td width='80' class='xian'>";
            }
        }
        $("#all_TicketOrder").html(html);
        if (orderInfo.pageCount == 0) {
            $("#allEmptyOrder").attr("style", "");
        }
        else {
            $("#allEmptyOrder").attr("style", "display:none");
        }
    }

    ashx文件,json

    public class OrderHandler : IHttpHandler
    {
        BLLtourol_B2COrder blltourol_b2corder = new BLLtourol_B2COrder();
        System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
    
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
    
            string type = context.Request["type"];
            int userid = int.Parse(System.Web.Security.Membership.GetUser().ProviderUserKey.ToString());
            string name = context.Request["name"];
            bool? ispaid;
            if (context.Request["ispaid"] == "null")
            {
                ispaid = null;
            }
            else
            {
                ispaid = bool.Parse(context.Request["ispaid"]);
            }
            int payway = int.Parse(context.Request["payway"]);
            string bdate = context.Request["bdate"];
            string edate = context.Request["edate"];
            int pageindex = int.Parse(context.Request["page"]) - 1;
            int pagesize = 10;
            if (type == ((int)EnterpriseType.景区).ToString())
            {
                context.Response.Write(GetAtractionView(userid, ispaid, payway, name, bdate, edate, pageindex, pagesize));
            }
        }
    
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    
        public string GetAtractionView(int userid, bool? ispaid, int payway, string name, string bdate, string edate, int pageindex, int pagesize)
        {
            int count = 0;
            DataTable dt = blltourol_b2corder.GetList4TableTicket(userid, ispaid, payway, name, bdate, edate, pageindex, pagesize, out count);
            return jss.Serialize(new ProductOrder2() { pageCount = (int)Math.Ceiling(count * 1.0 / 10), listPo = list4ticket(dt, count) });//把list转换为JSON格式的字符串
        }
    
        public List<ProductOrder> list4ticket(DataTable dt, int count)
        {
            List<ProductOrder> listPv = new List<ProductOrder>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ProductOrder pv = new ProductOrder();
                pv.orderid = dt.Rows[i]["Orderid"].ToString();
                pv.name = dt.Rows[i]["TicketName"].ToString();
                pv.upname = dt.Rows[i]["Name"].ToString();
                pv.createtime = DateTime.Parse(dt.Rows[i]["Createtime"].ToString()).ToString("yyyy-MM-dd");
                pv.endtime = DateTime.Parse(dt.Rows[i]["Endtime"].ToString()).ToString("yyyy-MM-dd");
                pv.totalmoney = dt.Rows[i]["TotalMoney"].ToString();
                pv.paystate = dt.Rows[i]["Paystate"].ToString();
                pv.payway = dt.Rows[i]["Payway"].ToString();
                pv.state = dt.Rows[i]["State"].ToString();
                listPv.Add(pv);
            }
            return listPv;
        }
    }
    
    public class ProductOrder
    {
        public string orderid { get; set; }
        public string name { get; set; }
        public string upname { get; set; }
        public string createtime { get; set; }
        public string endtime { get; set; }
        public string totalmoney { get; set; }
        public string paystate { get; set; }
        public string payway { get; set; }
        public string state { get; set; }
    }
    
    public class ProductOrder2
    {
        public int pageCount { get; set; }
        public List<ProductOrder> listPo { get; set; }
    }
  • 相关阅读:
    留言板
    移动端开发
    css3的伪类
    JQuery移除事件
    关于offset,你知道多少?
    关于section-scroll插件:
    jQuery响应式弹出层和对话框插插件magnific-popup.css
    col-lg-8 col-lg-offset-2
    关于渐变属 gradient:
    关于 window.onresize
  • 原文地址:https://www.cnblogs.com/TivonStone/p/3532614.html
Copyright © 2011-2022 走看看