【发布时间】:2010-09-20 20:27:56
【问题描述】:
这是我的 aspx 文件代码:
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) {
}
});
这是我的网络服务方法:
[WebMethod,ScriptMethod(UseHttpGet=true)]
public bool GetProductSubCategory(int productCategoryId)
{
//do some stuff
return true;
}
问题是jQuery函数失败并出现以下错误:
{"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"}
通过使用 Firebug,jQuery 请求的 URL 是
http://192.168.1.100:8888/WebService/DsmWebServices.asmx/GetProductSubCategory?%27productCategoryId%27=%2710%27
【问题讨论】:
-
为什么
"'10'"周围有多余的引号? (实际上使它不是整数....)
标签: asp.net jquery web-services asp.net-ajax