Ashx+Jquery(Ajax)案例

本文介绍了一个利用jQuery发起AJAX请求至ASHX文件来获取指定客户的信用额度的过程。具体步骤包括:通过GET方式发送请求到GetCredit.ashx,将客户ID作为参数传递;ASHX端则根据提供的客户ID查询数据库并返回相应的信用额度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



jquery端:            

      function GetCredit(credit) {
        $.ajax({
            type: "GET",
            url: "../Ashx/GetCredit.ashx",
            customerID: 'text',
            cache: false,
            data: { customerID: credit },
            success: function (result) {
                $("#<%=hidCredit.ClientID %>").val(result);
                alert("当前可用预存款:" + result + "元");
            }
        })

 

Ashx端:

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string credit = "0";

            if (!string.Empty.Equals(SalesCommon.GetIsNullOrEmpty(context.Request.QueryString["customerID"])))
            {
                string customerID = context.Request.QueryString["customerID"];
                string sql = "select credit from crm_customer where
customer_id=@customerID";
                sql = SqlUtil.setNumber(sql, "@customerID", customerID);
                DataTable dt = SalesCommon.QueryTable(sql);

                if (dt != null && dt.Rows.Count > 0 && !string.Empty.Equals(SalesCommon.GetIsNullOrEmpty(dt.Rows[0]["credit"]))) credit = dt.Rows[0]["credit"].ToString();
            }

            context.Response.Write(credit);
            context.Response.Cache.SetNoStore();
            context.Response.Flush();
        }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值