Ajax请求不调用WebMethod

时间:2019-04-17 23:17:02

标签: ajax webmethod onclientclick

我的页面上有一个Ajax请求,应该调用一个Web方法。

function CheckData() {

    var recordID = $('#recordID').val(); 
    $.ajax({
        type: "GET",
        url: "MyPage.aspx/CheckIfExist",
        data: "{'recordID':'" + recordID + "'}",
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        error: function (data) {
            alert(data);
            return false;
        },
        success: function (data) {
            alert("yes");
            return true;
        }
    });


    //return false;
}

我有一个调用该函数OnClientClick的asp按钮:

   <asp:Button ID="btnIssuerRemove" runat="server" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" 
        CausesValidation="false" CommandName="Remove" Text="Remove" OnCommand="issuerCommand_Click" OnClientClick="return CheckData()"/>

但是,该函数不会调用我的代码隐藏方法:

[System.Web.Services.WebMethod]
public static string CheckIfExists(string recordID)
{
    string test = recordID;
    return "record exists";
}

那是为什么?

0 个答案:

没有答案
相关问题