这是我第一次尝试从jQuery调用ASP.NET页面方法。我收到了一条状态500错误的responseText消息,指出找不到web方法。下面是我的jQuery $.ajax调用:
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);
        }
    });
}下面是我尝试调用的页面方法:
[WebMethod()]
private static void CancelPlan(int activePlanId, string ntLogin)
{
    StrategyRetrievalPresenter presenter = new StrategyRetrievalPresenter();
    presenter.CancelExistingPlan(offer, ntLogin);            
}我已经尝试过用和不用‘()’来修饰Web方法。有谁有主意吗?
发布于 2008-10-07 19:23:07
您的web方法需要是公共的和静态的。
发布于 2011-05-05 21:37:08
清理解决方案并重新构建。我见过webmethods抛出500个,直到你这么做。
发布于 2013-07-24 23:02:52
在你的方法之前添加public static ...
例如。
[WebMethod]
public static string MethodName() {}  https://stackoverflow.com/questions/179934
复制相似问题