The main benefit of using AJAX techniques in Web applications is an increased level of responsiveness once possible only in rich-client applications. Instead of waiting for a page reload or form post to update the user interface, the browser can send a discrete call to the server by using the XmlHttpRequest object while enabling the user to continue working.
A callback method on the client is then used to handle the Web request when it is completed. Compared to traditional applications, AJAX applications typically make smaller and more frequent data requests, loading data as needed rather than performing large data transfers up front. Figure 5-1 displays the traditional WSS page life cycle, in which the entire page is reprocessed as the user interacts with the data. In this traditional model, the page is requested and sent to the client as a whole. Upon page refresh, all required data must be reprocessed and resent, making data manipulations and navigation a disruptive activity. If multiple Web Parts exist on the page, each Web Part must be refreshed during the page request/response cycle. There is also significant overhead in the WSS page itself that would ideally be processed only once per user context rather than on each user interaction.
Figure 5-1: The traditional WSS Web page life cycle
In contrast to the traditional processing model, the AJAX approach to WSS programming includes a client runtime based on the ASP.NET AJAX Library, custom controller components patterned after the Model View Controller design pattern, and service-oriented XML data sources. Figure 5-2 illustrates the dynamic nature of the AJAX approach. Instead of one fat data stream being processed in the main request/response, individual components are responsible for their processing and can be individually refreshed and updated in response to user actions, events, or timer components. The user interface and data streams could also evolve over the client life cycle of the page-new components can be spawned from additional data sources and loaded into new components, all without reloading or posting the Web page. The Web page life cycle is much longer in an AJAX application because the page is not refreshed after the initial page load.
Figure 5-2: The AJAX WSS Web page life cycle
Utilizing the ASP.NET AJAX Framework in WSS and Microsoft Office SharePoint Server allows you to take advantage of AJAX technologies and methods while using a tested and supported framework that is fully integrated with ASP.NET 2.0. Before we learn how to deploy AJAX components in Web Parts, we will first look at AJAX architecture patterns and examine an AJAX application outside of the WSS context.