onReadyStateChange
As the name kind of implies, every time the "ready state" changes this function will be executed.
When the property readyState is 4 that means the response is complete and we can get our data.
Then the function that is repeatedly called can use the information depending on the readyState.
This basically ensures that only if the request has completed correctly your script will execute as you wish.
Kev
|