jquery 使用ajax调用c#后台方法

     $.ajax({
                        type: "get",
                        cache: false,
                        //方法所在页面和方法名     
                        url: "ShareCus.aspx",
                        data: { "name": para,"xml":"1" },
                        contentType: "application/json; charset=utf-8",
                        dataType: "text",
                        success: function (data) {
                            $('#<%=lb_dutyname.ClientID%>').text(data);
                        },
                        error: function (err) {
                            alert(err);
                        }
                    });

.cs

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request["xml"]==null)
            {
            }
            else
            {
                GetTip(Request["name"]??string.Empty);
           
            }

        }

    }

 public   void GetTip(string name)
    {
        string result = string.Empty;
        Users user = null;
        if (!string.IsNullOrEmpty(name))
        {

 result=name+"1111";
         }
        Response.Clear();
        Response.Write(result);
        Response.End();
    }

原文地址:https://www.cnblogs.com/keanuyaoo/p/3292279.html