ASP.NET jQuery的错误:未知的Web方法 [英] ASP.NET jQuery error: Unknown Web Method
本文介绍了ASP.NET jQuery的错误:未知的Web方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我第一次尝试调用从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.
这篇关于ASP.NET jQuery的错误:未知的Web方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文