Code: Ajax Callback Function

Chapter 8 - Ajax Optimization

Once the request has been initialized, assign a callback function to the onreadystatechange event handler. This function will be invoked as data is returned from the server.

xhr.onreadystatechange = function( ){responseCallback(xhr);};

Finally, send the request on its way....

xhr.send( );