WebMethod not being called

后端 未结 4 1592
-上瘾入骨i
-上瘾入骨i 2020-12-07 02:37

I am passing a javascript variable containing a string to the server via jquery.ajax. Although the \"success\" condition is called, the server-side WebMethod is never calle

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 02:43

    Try like this: JQuery:

                    var dataString = JSON.stringify({
                        contractName: contractName,
                        contractNumber: contractNumber
                    });
    
                    $.ajax({
                        type: "POST",
                        url: "CreateQuote.aspx/GetCallHistory",
                        data: dataString,
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (result) {
                            alert(result);
                                OpenLightBox('divDelete');
    
                        }
                    });
    

    ASPX.CS:

            [System.Web.Services.WebMethod]
            public static string GetCallHistory(string contractName, string contractNumber)
            {
                return "Nalan";
            }
    

提交回复
热议问题