ASP.NET jQuery的错误:未知的Web方法错误、方法、NET、ASP

2023-09-10 19:07:11 作者:霸道只是男人的本性×

这是我第一次尝试调用从jQuery的ASP.NET页面的方法。我得到一个状态500错误的responseText的消息,Web方法无法找到。这是我的jQuery $。阿贾克斯电话:

This is my first time attempting to call an ASP.NET page method from jQuery. I am getting a status 500 error with the responseText message that the web method cannot be found. Here is my jQuery $.ajax call:

function callCancelPlan(activePlanId, ntLogin) {
    var paramList = '{"activePlanId":"' + activePlanId + '","ntLogin":"' + ntLogin + '"}';
    $.ajax({
        type: "POST",
        url: "ArpWorkItem.aspx/CancelPlan",
        data: paramList,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function() {
            alert("success");
        },
        error: function(xml,textStatus,errorThrown) {
            alert(xml.status + "||" + xml.responseText);
        }
    });
}

这里是页面的方法我试图拨打:

And here is the page method I am trying to call:

[WebMethod()]
private static void CancelPlan(int activePlanId, string ntLogin)
{
    StrategyRetrievalPresenter presenter = new StrategyRetrievalPresenter();
    presenter.CancelExistingPlan(offer, ntLogin);            
}

我已经通过装饰Web方法有和没有括号()尝试了这一点。任何人都有一个想法?

I have tried this by decorating the Web Method with and without the parens'()'. Anyone have an idea?

推荐答案

您的Web方法必须是公开的和静态的。

Your web method needs to be public and static.