asp.net - 与服务器通信时发生错误

标签 asp.net json jquery-jtable

我在 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(对象目标,IDictionary2 个参数)\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/

相关文章:

json - 使用 Powershell 查找和替换嵌套的 JSON 值

javascript - 将 jQuery/JavaScript 函数应用于 jTable 检索的 SQL 数据

jquery - 如何在删除时刷新 jQuery jTable?

javascript - 使用 Javascript 添加行,但它显示然后变得不可见

c# - 合并多个来源的数据,在 ASP.Net GridView 中显示

php - 文件获取内容()错误: "Failed to open stream: HTTP request failed! HTTP/1.1 403 ModSecurity Action"

c++ - Qt:QScriptValueIterator 有一个额外的元素

c# - 如何使用VS2010在 'Person or Group'字段中插入数据?

asp.net - 控制对表单字段的访问的最佳实践

javascript - 在 history.pushState 中保存当前的 js 对象