Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Binod Pant on Feb 18, 2009 06:20
open dhtmlx forum
How to handle errors in dhtmlxAjax

Does dhtmlxAjax have support for Ajax error handling. For example, if the server code crashes, how do we know an error occurred? I have a servlet based server, which I can use to return various status codes. Does dhtmlxAjax allow me to check these codes, and perform appropriate client-side actions?
Answer posted by Support on Feb 18, 2009 08:53
When used separately dhtmlxAjax doesn't provide any special error handlers, but you can use 

dhtmlxAjax.get(url,function(result){
     if (!result.xmlDoc.responseXML) alert(result.xmlDoc.responseText); //if xml is not valid - output response
    else{
       //default action
    }
});

more complex validation can be organized as 

dhtmlxAjax.get(url,function(result){
       result.getXMLTopNode("name_of_top_node");
      //default action
});

dhtmlxError.catchError("LoadXML",function(type,description,details){
      alert(details[0].responseText);
     ///code here will be called for all xml loading errors
})