Search code examples
asp.netjsonjquery-jtable

An error occured while communicating to the server


Im using jTable in my code in jquery modile, I get parameter from query string and bind to jtable, but im getting error:An error occured while communicating to the server.

here is my code

  <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"] %> ')
                });
            });

my webmethod is

[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 };
    }
}

Anybody could please help me. How to call $('#ResultContainer').jtable('load', {.. on pageload?

Edit:

Im getting this message inn Response {"Message":"Invalid web service call, missing value for parameter: \u0027org\u0027.","StackTrace":" at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary2 parameters)\r\n at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary2 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"}


Solution

  • solved by passing values to jtStartIndex, jtPageSize, jtSorting) Thanks