SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot alfred3x's Avatar
    Join Date
    Aug 2003
    Location
    Toronto
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding property to XMLHttpRequest Object in IE

    I've created a small AJAX library for our application. We send the response data back as JSON in responseText. So far so good.

    Before we invoke the response handler, I'm putting the eval'ed responseText in the request object like so:

    Code:
    req.respText = eval('(' + req.responseText + ')');
    This works in FF but breaks in IE 6. (*gasp*)

    I finally got the Microsoft Script Editor yesterday, so I could play with the values and see what was going on. Kind of... I'm still in the dark. For some reason, it won't let me add a property to req.

    Can anyone explain why/how it prevents me from doing so?

    Conceivably I could add the eval'ed responseText to the response handler function, but that would break the API, and would require us to modify a bunch of existing functions.

    Thanks,
    - AAA
    - A. Alfred Ayache
    PHP/MySQL ZCE

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi AAA,

    There's nothing wrong with your code. As you've discovered, IE7's XMLHttpRequest object does not allow expando properties. Evidently it is not really a true "native" object.

  3. #3
    SitePoint Zealot alfred3x's Avatar
    Join Date
    Aug 2003
    Location
    Toronto
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Mike. I suspected as much. So now I can go ahead and break my API with a clear conscience. Not that big a deal...

    But the IE developers should be ashamed of themselves.

    - AAA
    - A. Alfred Ayache
    PHP/MySQL ZCE


Bookmarks

Posting Permissions

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