This is my aspx file code:
var DTO = { "'productCategoryId'": "'10'" };
$.ajax({
type: "GET",
url: "/WebService/DsmWebServices.asmx/GetProductSubCategory",
data: DTO,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
window.alert("success");
},
error: function (msg) {
}
});
This is my web service method:
[WebMethod,ScriptMethod(UseHttpGet=true)]
public bool GetProductSubCategory(int productCategoryId)
{
//do some stuff
return true;
}
The problem is that the jQuery function fails with the following error:
{"Message":"Invalid web service call, missing value for parameter:
\u0027productCategoryId\u0027.","StackTrace":" at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2 parameters)\r\n at
System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters)\r\n at
System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n at
System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}
By using Firebug, the URL jQuery requested was
http://192.168.1.100:8888/WebService/DsmWebServices.asmx/GetProductSubCategory?%27productCategoryId%27=%2710%27