views:

1943

answers:

3

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);            
}

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

+7  A: 

Your web method needs to be public.

tvanfosson
Well, that was a stupid mistake. Thanks, though.. ;)
Mark Struzinski
what if I have this error when then method is public?
Victor Rodrigues
A: 

restart your iis ..............

tae
A: 

Restart your IIS or close virtual port VS 2008.

hope this help, tae

tae