custom error capturing

Hi again,
I have been playing around with the code to try to captur custom error states.
In my webapp I check for session state to see if the current user is logged in or not, and I was hoping to be able to use the dp “invalid” state to alert the user that they are no longer logged in (stopping the edit in the process).

In my calendar script I have the following after setting the dp var up:

dp.defineAction("invalid",function(sid,response){ var message = response.getAttribute("message"); alert(message); return false; })

and in my saveload.asp I have the following being written as xml response in case the user session has expired:

<data><action type='invalid' sid='"&Request.Form("ids")&"' message='User is not logged in' /></action></data>

in a sample the actual xml generated is:

<?xml version="1.0" encoding="ISO8859-1" ?> <data> <action type='invalid' sid='1298298817235' message='User is not logged in' /></action> </data>

The alert is never triggered and instead I get a “message from webpage” which just shows the actual xml generated, not the “message” part.

Any suggestions?

EDIT: The ultimate goal here is to redirect the user to a login page instead of the alert popping up. Something like:

dp.defineAction("invalid",function(sid,response){ parent.location.replace('mydomain/loginpage.asp'); })

EDIT 2: The above actually works… but the alert doesn’t… weird. complains about something being “undefined”. My guess is on the response, message or both. Or maybe the sid. Who knows. At least I have got it to redirect to my login page if the user’s session has expired. Still, it would be nice to know why the alert doesn’t work…

The alert is never triggered and instead I get a “message from webpage” which just shows the actual xml generated, not the “message” part.

Which means response is not a valid XML

  • has invalid syntax
  • has invalid content type
  • has whitespaces before start of <?xml

By the way you can catch such error by using

dhtmlxError.catchError("LoadXML", function(){ alert("Error"); });

ok. thx, will check my code.