2.4. Summary

This chapter introduced you to several Ajax techniques for client-server communication. It began with an HTTP primer, exploring HTTP requests and responses. You learned about the format of HTTP messages and the differences between a GET request and a POST request. The concepts of headers and message bodies were introduced.

The first Ajax technique you learned was the hidden frame technique, which uses a frame with a width or height of zero, effectively hiding it from the user. This technique uses JavaScript calls to and from the hidden frame to facilitate the client-server communication. Using the hidden frame technique, you learned how to send both GET and POST requests.

Next, you learned about replacing hidden frames with hidden iframes. Because iframes can be created dynamically using JavaScript, this may be a preferable way to initiate client-server communication in modern browsers. The same techniques were used as with hidden frames, although iframes provide a bit more flexibility in the design of your pages.

The chapter also introduced the use of XHR for client-server communication. You learned that Internet Explorer, Mozilla Firefox, Safari, and Opera all support some form of XHR object, and some extra coding is necessary to detect these differences. The differences between asynchronous and synchronous requests were explained, and you learned how to make GET and POST requests using XHR. You also learned how to use request and response headers along with HTTP ...

Get Professional Ajax, 2nd Edition 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.