Search code examples
zend-frameworkgridjqxgridjqxwidgets

"SyntaxError: JSON.parse: unexpected character" error on loading jqxgrid in zend


I am using zend with jqxgrid.

While navigating to the page(eg: test.com/employee) containing jqxgrid, the grid simply works and loads the required data to the grid.

But when I try to navigate the same page by passing the parameter(eg: test.com/employee/id/1), the grid doesnot load. I’ve used loadError on the dataAdapter as below and printed the error

var dataadapter = new $.jqx.dataAdapter(source,{
loadError: function (xhr, status, error) { alert(‘Status=’+status+’, Error=’+error); }
});

The result of the alert is shown as: “Status=parsererror, Error=SyntaxError: JSON.parse: unexpected character”

I want to load the grid according to the “id” passed through navigation URL but its not working. So, what is the solution to this problem?

Does the jqxgrid takes the parameter /id/1 from the navigation URL while calling ajax?

Thank you in advance.


Solution

  • This was due do the routing error.

    When I replaced the navigation URL test.com/employee/id/1 with test.com/employee?id=1 , it worked as expected.