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