Section 1.2. AJAX Defined


1.2. AJAX Defined

AJAX, originally defined by an article written by Jesse James Garrett in February 2005, meant "Asynchronous JavaScript+XML." Although that acronym is amusing, it doesn't tell the full story. AJAX is a secondary path of communication from the JavaScript environment on the user's Web browser to your server. The use of AJAX causes changes in the typical page flow that you see in a normal Web application. With AJAX, requests now happen more often and may result in smaller responses of non-HTML data.

To get a true sense of what this really means, let's look at the communication flow of a normal Web application (see Figure 1-1). It's composed of two types of network activity: user-initiated HyperText Transfer Protocol (HTTP) requests (typing in a URL or clicking on a link) and responses from the server. In Web applications, most of the user requests contain data from a form, and the server responses are generated on the fly by a programming language such as PHP or Java. In the normal Web application model, the user always generates requests, so it's possible for a high rate of page requests to happen by someone clicking quickly, but in general, the request rate is low, with random amounts of time between each request.

Figure 1-1. Web application request flow


An AJAX Web application takes the normal communication flow of a Web application and adds a new type of request. To your server, this looks just like a normal page request (although in most cases, its data will be in a different format), but to the Web browser, it is different. It's a request that won't require a page reload on completion, and it doesn't have to be directly initiated by a user. In many cases, these AJAX requests will be small and might, for instance, take the form of a request to validate a field or to preload some data. However, the requests can also be large. For instance, they might submit a form through JavaScript or return Hypertext Markup Language (HTML) that will be used to replace the content on part of the page. A sample AJAX communication flow is shown in Figure 1-2. If you look at an AJAX application's requests over time and compare them to a normal Web application, you can pick out which is which just by seeing their request frequency. A comparison between the two is shown in Figure 1-3.

Figure 1-2. AJAX application request flow


Figure 1-3. Normal Web application requests versus AJAX requests


This change in frequency can greatly affect your ability to host an AJAX Web application. Your servers now have to be able to handle much higher request rates from the same number of users. This can be especially hard if each AJAX request takes just as much processing as a normal page load.




Understanding AJAX(c) Using JavaScript to Create Rich Internet Applications
Understanding AJAX: Using JavaScript to Create Rich Internet Applications
ISBN: 0132216353
EAN: 2147483647
Year: N/A
Pages: 154

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net