Forum







Hi,
When there is an error in a server side script (php), the grid displays the messsage "Loading..." endlessly. Would you please let me know how to handle exceptions (errors) in a server side script so that I can display error messages when there were problems with the server side script?
Regards,
Daniel
10:13

03/07/2008

Hello,
I got the same problem, too.
Did u use XML or Json? I tried the example using Json
and the File is made in php, but don´t know if it is in the correct
way. I use eclipse pdt and started the the php file with “start as php script” and the result in the console is like:
localhost{”page”:”1″,”total”:1,”records”:”7″,”rows”:[{"id":"15","cell":["15","2012-12-20","15","12.00","35.00","5.00","jawoll"]},{”id”:”554″,”cell”:["554","2012-08-20","142","4.00","44.00","4.00","52"]},{”id”:”5544″,”cell”:["5544","0000-00-00","4","754.00","11.00","152.00","122200"]},{”id”:”10020″,”cell”:["10020","0000-00-00","12","125.00","12.00","122.00","jo"]},{”id”:”10255″,”cell”:["10255","0000-00-00","15","44.00","111.00","24.00","kein text"]},{”id”:”102554″,”cell”:["102554","2015-10-19","15","45.00","41.00","2.00","1222"]},{”id”:”151223″,”cell”:["151223","0000-00-00","1","15.00","12.00","12.00","1112"]}]}
I put some dummy data in the Database, but I guess these are irrelevant.
Another thing is that I have the doubt that the variables are not received corretly received with the _GET expression.
For example: $limit = $_GET['rows'];
In the php i have to set $limit manually to 10, otherwise i get a “division by zero” error from this expression:
$total_pages = ceil($count/$limit);
best regards
jan
Thank you for the reply. But I was wondering how a grid knows when there was an error in the server scripts (php).
Let's say that I have a grid that calls a server script (php) which connects to MySQL server and returns result to the grid. And let's say that the server script could not connect to the MySQL server (or there was an SQL error or whatever…) Then, how I would like to handle those exception is for the php script to return some kind of generic error message to the grid so that the grid knows that there was an exception in the server script and displays an error message instead of showing the “Loading…” message endlessly.
I know that there is an example how to handle this with the Formedit using the callback function. However, I could not find out how to do this same type of thing for the main grid.
I would really appreciate if anyone can show me a snippet for it. Or please let me know if my questions is not clear enough.
Regards,
Daniel
03:07

Moderators
30/10/2007

Use loadError(xhr,st,err) event more info in this forum topic Releases
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Thank you Tony.
In 3.2rc, I tried loadError() function as below.
loadError: function (xhr,st,err){
alert("Error"+": "+st+"\\n"+xhr.responseText);
},
It seemed that the function loadError() worked beautifully since it caught the server error and displayed it. (Please see the screen shot: http://fact-dev.tech.northwest.....rerror.gif)
Now, the problem is that I don't know why I am getting the parsererror message.
I'm using json_encode as below.
<?php echo json_encode($responce); ?>
And the result of the function json_encode() looks OK to me. For a better readability, I reformatted the result as below:
{
"page":"1",
"total":1,
"records":"6",
"rows":[
{"id":"2008","cell":["2008","2007-2008","No"]},
{"id":"2007","cell":["2007","2006-2007","Yes"]},
{"id":"2006","cell":["2006","2005-2006","No"]},
{"id":"2005","cell":["2005","2004-2005","No"]},
{"id":"2004","cell":["2004","2003-2004","No"]},
{"id":"2003","cell":["2003","2002-2003","No"]}]
}
Do you have any idea why I'm getting the "parsererror" message I would really really appreicate any help on this.
Regards,
Daniel
Thank you Tony.
In 3.2rc, I tried loadError() function as below.
loadError: function (xhr,st,err){
alert("Error"+": "+st+"\\n"+xhr.responseText);
},
It seemed that the function loadError() worked beautifully since it caught the server error and displayed it. (Please see the screen shot: http://fact-dev.tech.northwest.....rerror.gif)
Now, the problem is that I don't know why I am getting the parsererror message.
I'm using json_encode as below.
<?php echo json_encode($responce); ?>
And the result of the function json_encode() looks OK to me. For a better readability, I reformatted the result as below:
{
"page":"1",
"total":1,
"records":"6",
"rows":[
{"id":"2008","cell":["2008","2007-2008","No"]},
{"id":"2007","cell":["2007","2006-2007","Yes"]},
{"id":"2006","cell":["2006","2005-2006","No"]},
{"id":"2005","cell":["2005","2004-2005","No"]},
{"id":"2004","cell":["2004","2003-2004","No"]},
{"id":"2003","cell":["2003","2002-2003","No"]}]
}
Do you have any idea why I'm getting the "parsererror" message I would really really appreicate any help on this.
Regards,
Daniel
My baaaad.
I realized that I was using unnecessary header information in my server script below. I commented out those and it worked perfect!
Thanks Tony!
if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
header("Content-type: application/xhtml+xml;charset=utf-8");
} else {
header("Content-type: text/xml;charset=utf-8");
}
Most Users Ever Online: 715
Currently Online:
47 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66