Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    165
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Debugging [Error Object] in try/catch statement

    Hi there,
    I'm using ajax to send and receive data, and use cross-domain scripting, this works fine when you add the domain to your IE security settings/Intranet sites list, I want to be able to catch the message IE would normally give you: "This page is accessing information that is not under its control. This poses a security risk... etc... ", and display the message at a different time with a list of other things, I claim myself that I have a brain but cannot figure out for the life of me the properties on the error object caught in the catch statement, example:

    Code:
    try
    {
          xmlHttpReq.open("POST", sURL, false);
    }
    catch(e)
    { 
         alert("error.toString(): " + e.toString());
         alert("error.id: " + e.id);
    }
    The .asString() returns [Object Error] which is great, but I cannot find any of the properties which give info about the actual error, I've tried .description/.message, the documentation I've found doesn't seem to help, am I viewing an IE error object or an object setup by the previous command e.g. xmlHttpReq.open ?

    Thanks for help

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Do this:

    Code:
    for(prop in e){
      alert(e + ": " + e[prop]);
    }
    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •