MSDN Magazine - February 2008 - (Page 36) SPECIAL ADVERTISING SECTION The most recent buzzword to shake the foundations of Web programming is AJAX (short for Asynchronous JavaScript and XML). AJAX incorporates several techniques for improving user experience—allowing browser-based applications to use the same elements used in native applications outside the browser. HTML can be a poor medium for building rich user interfaces, but AJAX breathes life into HTML. The cost of adding AJAX to a Web site can be prohibitive, however, because it requires writing JavaScript code and getting it to work in a variety of browsers (or even different versions of the same browser). Help is on its way in the form of AJAX frameworks. A framework can dramatically reduce development and maintenance costs by providing libraries of prewritten code. Microsoft’s AJAX framework drastically reduces the cost of building and maintaining AJAX-enabled Web sites. Some of the most complex AJAX scenarios can be implemented in a matter of minutes (without hand-coding any JavaScript) by simply adding a control to a Web form. And because millions of Web designers and developers are already familiar with the ASP.NET AJAX programming model, they are able to get up and running on ASP.NET AJAX in no time. We are not talking about the future here, we are talking about today. Microsoft ASP.NET AJAX is here now: ready to deliver the goods and help advance the state of the Web. Moving to the Next Level Making Websites more interactive AJAX was designed to cure many of the ailments that afflict browser-based applications. A classic use of AJAX is to eliminate the flashing and flickering that often happens between Web page views. This flashing and flickering occurs when the entire page reloads due to a user action, such as sorting a table or clicking a button. AJAX replaces traditional page loads with asynchronous calls and callbacks. With AJAX, the browser does not reload the entire page. Instead, it uses JavaScript to make a server request and then updates the content on the page with the data returned in the response. This partial-page loading technique is illustrated in Figure 1. Writing partial-page loading code without the benefit of an AJAX framework is tedious and time-consuming, and it is easy to make serious errors. Phase 1 in the AJAX Issues Facing ASP.NET Developers Web programmers use JavaScript to make Web pages richer and more interactive. However, JavaScript is difficult to author and debug when used to implement complex user interface elements such as expandable and collapsible panels, progress controls, and even auto-completion user interface helpers. It takes more code and more time to write such behaviors in JavaScript than other popular languages commonly used in server-side Web development today. Web developers today still face the extremely difficult task of creating applications which look and function consistently across several browsers. Typically, with client-side JavaScript, as complexity increases, portability and maintainability both decrease. Testing with the most popular Web browsers becomes a tremendous undertaking, which adds to the implementation and maintenance costs. So many Web browser combinations exist, for example, Windows and Internet Explorer, Mac OS and Apple Safari, or Linux and Mozilla Firefox. Once you factor in the many different versions of both operating systems and browsers in use today, you quickly realize it takes tremendous IT resources to write and verify code that works correctly. ASP.NET, on the server-side, eliminates this cross-browser problem by generating standards-compliant markup and script. ASP.NET AJAX extends the server-side capabilities of ASP.NET by adding a convenient client-side framework that helps Web developers build applications that work across the widest combination of browsers and operating systems in common use today. Browser 1 Browser submits conventional HTTP request to server Web Servers 2 Server responds with content; browser renders that content 3 Browser submits asynchronous XML-HTTP request to server; UI remains responsive; page doesn’t flash 4 XML-HTTP request completes, JavaScript refreshes portion of page affected by response Figure 1: Using AJAX to perform partial-page loading
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.