Engine Methods and Properties

When we create the callback method for the request, we will need to check the ready state of the response in order to know that it is completed and ready to be parsed. In order to check the ready state with our engine, we will call our first Ajax method named checkReadyState. Following is a snippet of our onResponse method, which will make this call:

function onResponse()
{
    if(Ajax.checkReadyState('loading') == "OK")
    {
        // Parse response here
    }
}

After the ready state of the response is complete, we can parse the data as we did in Chapter 3. In order to parse the data, the Ajax object has another method named getResponse. This method will provide the correct data format based on the header response from the server. ...

Get Ajax for Web Application Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.