我在 jquery modile 的代码中使用 jTable,我从查询字符串获取参数并绑定(bind)到 jtable,但我收到错误:与服务器通信时发生错误。
这是我的代码
<script type="text/javascript">
$(document).delegate('.ui-page', 'pageshow', function () {
$('#ResultContainer').jtable({
title: 'Search List',
paging: true, //Enables paging
pageSize: 10, //Actually this is not needed since default value is 10.
sorting: true, //Enables sorting
actions: {
listAction: "SearchResult.aspx/GetSearch"
},
fields: {
Ref: {
title: "Ref",
width: '30%'
},
Trademark: {
title: 'Trademark',
width: '30%'
}
}
});
$('#ResultContainer').jtable('load', {
org: '<%= Request["org"] %> ',
catchword: ('<%= Request["tm"] %> ')
});
});
我的网络方法是
[WebMethod(EnableSession = true)]
public static object GetSearch(string org, string catchword, int jtStartIndex, int jtPageSize, string jtSorting)
{
List<Coverage> tm = new List<Coverage>();
try
{
//Get data from database
using (ORepository repository = new ORepository())
{
tm = repository.getCoveragebyTM(catchword, org,0,10,"catchword");
int cnt = tm.Count;
return new { Result = "OK", Records = tm, TotalRecordCount = cnt };
}
}
catch (SqlException ex)
{
return new { Result = "ERROR", Message = ex.Message };
}
}
任何人都可以帮助我。如何调用 $('#ResultContainer').jtable('load', {..
页面加载时?
编辑:
我在回复中收到此消息
{“Message”:“无效的 Web 服务调用,缺少参数值:\u0027org\u0027。”,“StackTrace”:“位于 System.Web.Script.Services.WebServiceMethodData.CallMethod(对象目标,IDictionary2 个参数) )\r\n 在 System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(对象目标,IDictionary
2 个参数)\r\n 在 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"}
最佳答案
您没有为组织和口号参数传递任何值。您可以使用 listAction 来做到这一点:“SearchResult.aspx/GetSearch?org=asd&catchword=asd”
此外,您还可以使用 firebug 或 chrome 开发工具检查网络包以查看错误详细信息。
关于asp.net - 与服务器通信时发生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15523605/