What Is Ajax?


Ajax enables you to enhance the user interfaces of Web applications by means of asynchronous postbacks and dynamic client-side Web page manipulation. The term Ajax was invented by Jesse James Garrett and is shorthand for “Asynchronous JavaScript and XML.”

Tip 

Note that Ajax is not an acronym, which is why it is not capitalized as AJAX. However, it is capitalized in the product name ASP.NET AJAX, which is Microsoft’s implementation of Ajax, as you will see in the next section of this chapter.

From its definition, it is obvious that Ajax involves both JavaScript and XML. However, the Ajax programming requires the use of other technologies as well, which are described in the following table.

Open table as spreadsheet

Technology

Description

HTML / XHTML

HTML (Hypertext Markup Language) is the presentation and layout language used by Web browsers to render information in a graphical user interface. In the previous two chapters, you have seen how HTML achieves this functionality and how ASP.NET generates HTML code. Extensible HTML (XHTML) is a stricter definition of HTML that uses XML structure.

CSS

CSS (cascading style sheets) is a means by which HTML elements can be styled according to rules defined in a separate style sheet. This enables you to apply styles simultaneously to multiple HTML elements and to swap styles to change the way a Web page looks without HTML modifications. CSS includes both layout and style information, so you can also use CSS to position HTML elements on a page. You have seen how to do this in the examples in previous chapters.

DOM

The DOM (Document Object Model) is a means of representing and manipulating (X)HTML code in a hierarchical structure. This enables you to access, for example, “the second column of the third row in table x” in a Web page, rather than having to locate this element using more primitive text processing.

JavaScript

JavaScript is a client-side scripting technology that enables you to execute code inside a Web browser. The syntax of JavaScript is similar to other C-based languages, including C#, and provides variables, functions, branching code, loop-ing statements, event handlers, and other familiar programming elements. However, unlike C#, JavaScript is not strongly typed, and debugging JavaScript code can be notoriously difficult. In terms of Ajax programming, JavaScript is a key technology, since it allows dynamic modifications to Web pages by way of DOM manipulation - among other functionality.

XML

XML, as you have seen throughout this book, is a platform-neutral way to mark up data and is crucial to Ajax both as a way to manipulate data and as a language for communication between the client and the server.

XMLHttpRequest

Since Internet Explorer 5, browsers have supported the XMLHttpRequest API as a means of performing asynchronous communication between the client and server. This was originally introduced by Microsoft as a technology to access e-mail stored in an Exchange server over the internet, in a product known as Outlook Web Access. Since then it has become the standard way to perform asynchronous communications in Web applications, and is a core technology of Ajax-enabled Web applications. Microsoft’s implementation of this API is known as XMLHTTP, which communicates over what is often called the XML-HTTP protocol.

Ajax also requires server-side code to handle partial-page postbacks as well as full-page postbacks. This can include both event handlers for server-control events and Web services (see Chapter 37, “.NET Remoting,” for more information on Web services). Figure 34-1 shows how these technologies fit together in the Ajax Web browser model, in contrast to the “traditional” Web browser model.

image from book
Figure 34-1

Prior to AJAX, the first four technologies listed in the preceding table (HTML, CSS, the DOM, and JavaScript) were used to create what was known as Dynamic HTML (DHTML) Web applications. These applications were notable for two reasons: they provided a much better user interface, and they generally only worked on one type of Web browser.

Since DHTML, standards have improved, along with the level of adherence to standards in Web browsers. However, there are still differences, and an Ajax solution must take these differences into account. This has meant that most developers have been quite slow to implement Ajax solutions. Only with the advent of more abstracted Ajax frameworks (such as ASP.NET AJAX) has Ajax-enabled Web site creation really become a viable option for enterprise-level development.




Professional C# 2005 with .NET 3.0
Professional C# 2005 with .NET 3.0
ISBN: 470124725
EAN: N/A
Year: 2007
Pages: 427

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