在我的代碼中使用jTable在jquery modile中,我從查詢字符串中獲取參數並綁定到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是
[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', {..
on pageload?
編輯:
即時得到這個消息客棧響應 { 「消息」: 「無效的Web服務調用,缺少參數值:\ u0027org \ u0027。」, 「堆棧跟蹤」:」在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 System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context,WebServiceMethodData methodData,IDictionary`2 rawParams)\ r \ n System .Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext上下文,WebServiceMethodData methodData)「,」ExceptionType「:」System.InvalidOperationException「}
可能的路徑解決:的listAction: 「SearchResult.aspx/GetSearch」 是不正確,請檢查。 – 2013-03-20 12:36:25
我在ajax調用的幫助下檢查了它,它是工作函數Getdata()var pageUrl ='<%= ResolveUrl(「〜/ SearchResult.aspx」)%>' var DTO =「{org:'」('<%= Request [「org」]%>')+「',catchword:'」+('<%= Request [「tm」]%>')+「'」「; $ .ajax({type:「POST」, url:pageUrl +「/ GetSearch」, – Fluminda 2013-03-20 13:01:21
根據你的錯誤信息,你沒有正確傳遞一個值 – 2013-03-20 13:13:51