SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    May 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    OnReadystatefunction help

    hi there,

    i am learing xml parsing with javascript, but unable to understand the use of onreadystatechange function.

    can anyone plz help me with that.
    Thanx alot

  2. #2
    SitePoint Evangelist pip's Avatar
    Join Date
    Jun 2001
    Location
    Cape Town, South Africa
    Posts
    548
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've used the onReadyStateChange event a couple of times to check when a document is reloaded and ready. Whether it be a frame, iframe within my document or the actual document, you can attach the onReadyStateChange event to a document which has fully loaded, and once it starts navigating again, the onReadyStateChange event fires. You could then use it to check at intervals if the document.readyState value equals "complete" and perform additional scripting tasks as soon as this happens.Pip
    - Pip
    ---------------------------------------------------------------------------------
    Nothing takes the taste out of peanut butter quite like unrequited love.

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    unable to understand the use of onreadystatechange function
    It's an event handler just like onclick or onchange. However, onreadystatechange fires in response to data that is loading. When the data is loading, it goes through several stages before being fully loaded, and at each stage the onreadystatechange event handler fires. You need to detect when the data is fully loaded so you can read the data. You do that by assigning a function to onreadystatechange that checks the status of the data everytime onreadystatechange fires. The data could take 1 sec or 5 minutes to download, and you can't try to access the data until it is fully loaded. onreadystatechange is used to detect when the data has fully loaded.


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
  •