AJAX请求

来源:互联网 发布:淘宝第一美女 编辑:程序博客网 时间:2024/05/21 13:55

一、请求本页面后台【无刷新删除Repeater中的数据】:

1)、前台

<input type="button" value="删除" onclick="del(this,<%# Eval("id")%>)" />

。。。。。。。。

function del(obj, id) {
            if (confirm("确认要删除吗?")) {
                var merchantid = $("#HiddenField1").val();
                $.ajax({
                    url: "MerchantDetail.aspx",
                    data: { callback: 1, Mid: id, id: merchantid },
                    type: "POST",
                    async: true,
                    cache: false,
                    success: function (msg) {
                        if (msg > 0) {
                            alert("删除成功");
                            $(obj).parent().parent().remove();
                        }
                    }

                })
            }
        }

后台:请求其他页面

if (!IsPostBack)
            {

                if (!string.IsNullOrEmpty(Request.Params["callback"]))
                {
                    action = Request.Params["callback"];
                    int id = StringPlus.StrToInt(Request.Params["Mid"], 0);
                    Response.Write(DelAirCompany(id));
                    Response.End();
                }
            }

二、

前台【get请求(其他页面)】

<input type="button" value="编辑" onclick="edit(this,<%# Eval("id")%>,'<%# Eval("FMAAirCode")%>','<%# Eval("FAMAgencyFee")%>','<%# Eval("FMAReward")%>','<%# Eval("FMABillFee")%>','<%# Eval("FMARebeat")%>')" />

。。。。。。。。

function edit(obj, id, airCode, agencyFee, reward, billFee,rebeat) {
            var merchantId = $("#HiddenField1").val();
            var params = "&Mid=" + id + "&aircode=" + airCode + "&agencyfee=" + agencyFee + "&reward=" + reward + "&billfee=" + billFee + "&rebeat=" + rebeat;
            window.open('AddAirCompany.aspx?callback=2&id=' + merchantId + params, '', 'height=400,width=600,top=100,left=200,toolbar=no,location=no,status=no');
            return false;

 

后台:

string action = Request["callback"];

if (!IsPostBack)
        {

            if (action == "2")
            {
                //txtAirCode.Value =Request["aircode"].ToString();
                ddlAirCode.SelectedValue = Request["aircode"].ToString();
                txtAgencyFee.Value = StringPlus.DecToFormartDecimal(TypeParse.StrToDecimal(Request["agencyfee"].ToString(), 0.00M)).ToString();
                txtBillFee.Value = StringPlus.DecToFormartDecimal(TypeParse.StrToDecimal(Request["billfee"].ToString(), 0.00M)).ToString();
                txtReward.Value = StringPlus.DecToFormartDecimal(TypeParse.StrToDecimal(Request["reward"].ToString(), 0.00M)).ToString();
                txtRebeat.Value = StringPlus.DecToFormartDecimal(TypeParse.StrToDecimal(Request["rebeat"].ToString(), 0.00m)).ToString();
            }

}
原创粉丝点击