Ashx+Jquery(Ajax)案例

    xiaoxiao2021-03-25  142

    

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

     

    转载请注明原文地址: https://ju.6miu.com/read-21161.html

    最新回复(0)