【发布时间】:2016-09-09 11:23:08
【问题描述】:
我正在调用 Ajax,如下所示
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: 'employerbrowse.aspx/GetData',
dataType: "json",
data: '{ "jsondata":' + jsondata + ',"key":"' + getValue('id') + '"}',
success: function (data) {
callback(data);
},
error: function (error) {
callback(error.responseText);
}
});
调用没有转到 web 方法,错误显示如下
"Message":"无效的 Web 服务调用,缺少参数值: \u0027obj\u0027."`
我不知道发布数据有什么问题。 我使用 Ajax 调用发布的数据值,例如
{
"jsondata": {
"pagenumber": "0",
"sortColumn": "Name",
"sortDirection": "asc",
"rowPerPage": "10"
},
"key": "PPCrAV0oUGhy1cRdNEiN/ohdzAwD3+Qyyn5ozvhZ1B6STo0KrY+/Vggfnc4v12JS"
}
我在 Ajax 发布数据中找不到任何错误。
employeebrowse.aspx.cs 页面中的 Webmethod 我写的如下所示
[WebMethod(EnableSession = true)]
[ScriptMethod(UseHttpGet = false)]
public static JSONResponse GetData(JSONRequest obj)
{
JSONResponse objJSONResponse = new JSONResponse();
SessionHelper objSessionHelper = new SessionHelper();
return objJSONResponse;
}
我写的 JSONRequest 类如下所示
public class JSONRequest
{
public object jsondata;
public string key;
}
如果有人有任何想法,请分享。
谢谢。
【问题讨论】:
-
写成
public static JSONResponse GetData(object jsondata, string key)有区别吗?
标签: jquery asp.net json ajax asp.net-ajax