Fluminda
Fluminda

Reputation: 85

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"}

Upvotes: 2

Views: 6342

Answers (3)

Fluminda
Fluminda

Reputation: 85

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

Upvotes: 0

Deeper
Deeper

Reputation: 11

JTable execution result, there are two state identification, ok, and others. When the state is! Ok when your message will be reported if a non-digital state this error. Recommended as a state background using digital identification and correction within the source code.

            String error="{\"Result\":\"ERROR\",\"Message\":"+100+"}";
                    response.getWriter().print(error);
    if (data.Result != 'OK') {
                        if(data.Message == 100){
                            self._showError('未登录!请重新登录');
                        }else{
                            self._showError(data.Message);
                        }
                        //window.location.href="login.jsp";
                        return;
                    }
if (data.Result != 'OK') {
                        if(data.Message == 100){
                            self._showError('未登录!请重新登录');
                        }else{
                            self._showError(data.Message);
                        }
                        //window.location.href="login.jsp";
                        return;
                    }

Upvotes: 1

hikalkan
hikalkan

Reputation: 2282

You are not passing any value for org and catchword parameters. You can do it with listAction: "SearchResult.aspx/GetSearch?org=asd&catchword=asd"

Also, you can check network packages with firebug or chrome dev tools to see error detail.

Upvotes: 3

Related Questions