Read the XML after load for error handling

I have a grid that I load from the database:

oGrd.load("Objects_BRKR.ashx?action=Get");

If there is some sort of database error, I have some error handling that sends the back the relevant info in the XML.

<?xml version="1.0" encoding="utf-8"?> <rows> <result status="error" /> <error errorNo="8134" errorDescription="Oops! Blah, blah, blah" /> </rows>
The load may appear to be successful, just with zero rows being rendered.
However, I want to be able to look at the returned XML to determine if the status was “error” and then display an appropriate message to the user.

I was hoping the doAfterRefresh variant of load might help:

myGrid.load("grid.xml",doAfterRefresh);

But doAfterRefresh doesn’t appear to provide access to the XML response such as when you use window.dhx4.ajax.get:

window.dhx4.ajax.get("Objects_BRKR.ashx?action=Get", function(r){ var x = r.xmlDoc.responseXML; var result = x.getElementsByTagName("result")[0].attributes; var status = result.getNamedItem("status").nodeValue; if (status=="error"){ //display error dialog ] });

So, is there a way for me to access the XML after the load is finished to achieve my error handling requirement?

In the interest of just getting things to work asap, I’ve decided to not use the simple myGrid.load() function.

Here’s my solution, in case it proves useful to someone else:

function loadObjects(){ window.dhx4.ajax.get("Objects_BRKR.ashx?action=Get", function(r){ var t = r.xmlDoc.responseText; var x = r.xmlDoc.responseXML; var result = x.getElementsByTagName("result"); var status = result[0].getAttribute("status"); if (status!="error"){ oGrd.parse(t); }else{ //display error dialog var error = x.getElementsByTagName("error"); var errorDescription = error[0].getAttribute("errorDescription"); dhtmlx.alert({ title:"Database retrieval failed", text:"Oh, this is embarassing!<br><br>"+errorDescription, ok:"Ok", callback:function(){} }); } }); }