Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by crazysantu on Apr 15, 2008 22:41
open dhtmlx forum
error handling in grid to avoid load xml errors

Hi,
I am getting load xml errors frequently.
How can i get rid of these errors?
When there is no correct data coming from DB i am getting this errors.How to catch that exception so that load xml pop up will not come?
Answer posted by Support on Apr 16, 2008 02:08
You can catch error and prevent error message by using default error handling routine.

function myErrorHandler(type, desc, erData){
    //custom code can be placed here
    return false;
}
dhtmlxError.catchError("LoadXML", myErrorHandler);

The array contains additonal data related to error
    erData=[xmlHttpRequest , object]

First element - xmlHttpRequest object, which contain all data requested from server.
Second element - dhtmlx object, component which throw error while loading.

You can get any additional error info by checking xmlHttpRequest properties (xmlHttpRequest.responseText for example )
Answer posted by crazysantu on Apr 16, 2008 04:39

I am getting loadXML error and i found the answer for this to use like this

function myErrorHandler(type, desc, erData){
    //custom code can be placed here
    return false;
}
dhtmlxError.catchError("LoadXML", myErrorHandler);

 

I am having some doughts on the above code .

what are the parameters i have to give for myerrorhandler.I mean what is the value i have to give for "type" and "desc".And u said

erData array.I didnt understand what value we have to give for the "object" parameter.can u give any sample code for this along with custom code to be placed in myerrorHandler.

Answer posted by Support on Apr 16, 2008 05:16
you must not specify any parameters, they are sent to custom error handler by component code
In simplest case , if you need just block error message, the next will be enough

    dhtmlxError.catchError("LoadXML", function(){ return false; });
Answer posted by crazysantu@gmail.com on Apr 16, 2008 23:54

Thanx for ur update.

Where i can place this code line  "dhtmlxError.catchError("LoadXML", function(){ return false; });"

After mygrid.LoadXML("");  or before mygrid.LoadXML("");  ??

Answer posted by Support on Apr 17, 2008 02:26
It doesn't really matter, placing before loadXML is more safe approach, but it will work in any case.