I am calling a web method in aspx page from my js file using AJAX. I have set the method to be [WebMethod] and the page inherits from System.Web.Ui.Page class. Still it does not
The only thing I see missing is making the method static.
read this article
http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/
Try this
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string CustomOrderService(string id)
{
string result;
// code logic which sets the result value
result="some value";
return result;
}
Use Static String.
[WebMethod]
public static string CustomOrderService(string id)
{
string result;
// code logic which sets the result value
result="some value";
return result;
}
Decorate your CustomOrderService
method with:
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
Also, change your return data to:
return new JavaScriptSerializer().Serialize(result);