June 2015
Intermediate to advanced
192 pages
4h 8m
English
Once the server returns the result, you need a way to get that result from the XMLHttpRequest object and convert the result from a string to a JavaScript object.
The XMLHttpRequest object defines the onreadystatechange attribute to which you assign a function that is called periodically throughout the lifespan of a request. Here's our doAjax function in its entirety, including a function assigned to this attribute to monitor the request for completion:
function doAjax() { var xmlhttp; xmlhttp = new XMLHttpRequest(); var request = { call: "kf6gpe-7" }; xmlhttp.addEventListener("loadstart", loadstart, false); xmlhttp.addEventListener("progress", progress, false); xmlhttp.addEventListener("load", load, false); ...Read now
Unlock full access