Master AJAX, Part 1: Introduction to AJAX

xiaoxiao2021-03-31  215

Five years ago, if you don't know XML, you are a ugly ducklings who are not paid. 18 months ago, Ruby became the center of concern, I don't know if Ruby's programmer can only sit on the cold bench. Today, if you want to keep up with the latest technology, then your goal is AJAX.

However, Ajax is more than just a fashion, but it is a powerful way to build websites, and it is not as difficult as learning a new language.

But before explaining what is Ajax, let's take a few minutes to learn what Ajax is doing. Currently, there are two basic options when writing applications:

Desktop application web application

Both are similar, desktop applications typically use CD as media (sometimes downloadable from the website) and completely installed on your computer. Desktop applications may use the Internet to download updates, but run the code for these applications on the desktop computer. The web application runs on a Web server in somewhere - it is not surprising, to access this application through a web browser.

However, what is more important than the running code of these applications is how the application runs and how to interact with it. Desktop applications are usually very fast (just on your computer, do not wait for internet connection), with beautiful user interfaces (usually related to operating systems) and extraordinary dynamics. You can click, select, Enter, open the menu and submenu, you can patrol it everywhere, basically no waiting.

On the other hand, the web application is the latest trend, which provides services that cannot be implemented on the desktop (such as Amazon.com and eBay). However, accompanying the power of the Web is waiting, waiting for the server response, waiting screen refresh, wait for the request to return and generate a new page.

Obviously this is too simple, but the basic concept is. You may have guess that Ajax attempts to establish the functionality and interactivity of desktop applications, with bridges between the Updated web applications. You can use dynamic user interfaces and beautiful controls like desktop applications, just in the web application.

What are you waiting for? Let's take a look at how Ajax transforms the clumsy web interface into the Ajax application that can quickly respond quickly.

Old technology, new skill

When talking about Ajax, it is actually involved in a variety of technologies, and it is necessary to flexibly use it necessary to understand these different technologies (including the first few articles of this series will discuss these technologies respectively). Good news is that you may be very familiar with most of them, and better is that these technologies are easy to learn, not as difficult as a complete programming language (such as Java or Ruby).

Ajax's definition is in the way, Ajax is an abbreviation for Asynchronous JavaScript and XML (and DHTML, etc.). This phrase is Adaptive Path's Jesse James Garrett invented (see Resources), follows Jesse explanation, this is not a first letter abbreviation.

Below is the basic technique used by the Ajax application:

HTML is used to establish a web form and determine the fields used in other parts of the application. JavaScript code is the core code of running the AJAX application to help improve communication with the server application. DHTML or Dynamic HTML for dynamic update forms. We will use DIV, SPAN, and other dynamic HTML elements to mark HTML. Document Object Model DOM is used to handle the HTML structure and (in some cases) the XML returned by the HTML structure and (in some cases). Let's further analyze the responsibilities of these technologies. In the future article, I will discuss these technologies in the future, as long as they are familiar with these components and technologies. The more familiar with these code, the easier, easily transforming the zeroing of these technologies to truly grasp these techniques (and also truly open the gate of Web application development).

XMLHttpRequest object

An object to be understood may be the most strange to you, namely XMLHttpRequest. This is a JavaScript object that creates this object is simple, as shown in Listing 1.

Listing 1. Creating a new XMLHttpRequest object