Handling the Server Response with AJAX
A seemingly standard way to handle the server response when using AJAX:
http_request.onreadystatechange = nameOfTheFunction;
where nameOfTheFunction is an anonymous function that should look something like this:
if (http_request.readyState == 4) {
// good to go!
} else {
// still waiting...
}
The different types of states include:
- 0 (uninitialized)
- 1 (loading)
- 2 (loaded)
- 3 (interactive)
- 4 (complete)