首页 > 其他 > 详细

ajxa异步请求数据

时间:2015-01-21 20:15:35      阅读:330      评论:0      收藏:0      [点我收藏+]

ListData.cs 类


using System;

using System.Collections.Generic;

using System.Web;

using System.Text;

public class ListData

{

    private int pageSize;

    public int PageSize

    {

        get { return pageSize; }

        set { pageSize = value; }

    }


    private int records;

    public int Records

    {

        get { return records; }

        set { records = value; }

    }

    public ListData()

    {

    }

    public ListData(int pageSize, int records)

    {

        this.PageSize = pageSize;

        this.Records = records;

    }


    public string ToJson()

    {        

        System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();

        return serializer.Serialize(this);

    }

}


一般处理程序ashx:


  ListData ldata = new ListData();实例化类

  ldata.PageSize = pageSize;//每页显示多少条记录

  ldata.Records = recount;//总记录数


 context.Response.Write(ldata.ToJson());//输出到页面


页面接收值:


    $(function () {

var title = $("#Info_title").text(); //评论主题

        var url = ‘<wtl:system type="Systempath"></wtl:system>sitecn/conmmentOn/ConmmentOnListPage.ashx‘;//链接地址:一般处理程序地址

        var date = { ctent: "0", pageTopic: "page_indexs",title:title };

        $.post(url, date, function (getdata) {

            var tip = eval("(" + getdata + ")");

                    $("#page_count").html("" + tip.Records + "");//总条数

        $("#page_Size").html("" + tip.PageSize + ""); //每页显示几条

        });

    });


ajxa异步请求数据

原文:http://haihuiwei.blog.51cto.com/4789207/1606738

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!