Chapter 4. AJAX and Server Communication
The common thread of this chapter is server-side communications.
Performing asynchronous requests, using the IFRAME transport to submit
forms behind the scenes, serializing to and from JavaScript Object
Notation (JSON), and using JSONP (JSON with Padding) are a few of the
topics that are introduced in this chapter. You'll also learn about
Deferred, a class that forms the
lynchpin in the toolkit's IO subsystem by providing a uniform interface
for handling asynchronous activity.
Quick Overview of AJAX
AJAX[12] (Asynchronous JavaScript and XML) has stirred up
considerable buzz and revitalized web design in a refreshing way.
Whereas web pages once had to be completely reloaded via a synchronous
request to the server to perform a significant update, JavaScript's
XMLHttpRequest object allows them
to now behave much like traditional desktop applications. XHR is an
abbreviation for the XMLHttpRequest
object and generally refers to any operation provided the
object.
Web pages may now fetch content from the server via an asynchronous request behind the scenes, as shown in Figure 4-1, and a callback function can process it once it arrives. (The image in Figure 4-1 is based on http://adaptivepath.com/ideas/essays/archives/000385.php.) Although a simple concept, this approach has revolutionized the user experience and birthed a new era of Rich Internet Applications.
Figure 4-1. The difference between synchronous and asynchronous communication for a web application ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access