SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,046
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)

    onreadystatechange event?

    is onreadystatechange an event?

    Is it possible to do something like this:

    this.request.addEventListener('onreadystatechange',handler,false);

    were this.request is a XMLHTTRequest object.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Yes to all the above, though you may with to include IE in what you're doing as well.

    Either with advanced event registration with at least the following

    Code javascript:
    if (document.addEventListener) {
        this.request.addEventListener('onreadystatechange', handler, false);
    } else if (document.attachEvent) {
        this.request.attachEvent('readystatechange', handler);
    }

    Or if you know that the object event won't have more than one function assigned to it, you can use the standard event registration instead.

    Code javascript:
    this.request.onreadystatechange = handler;
    Last edited by paul_wilkins; Feb 22, 2008 at 01:39.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,046
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Listening for that event isn't working so I just used the standard event registration.


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
  •