How did Ajax come about? What are the advantages and disadvantages of using AJAX?

Source: Internet
Author: User


This article focuses on the details of Ajax, the origin of Ajax, the principle of Ajax, and the advantages and disadvantages of Ajax. Now let's see this article together.



What is Ajax



In fact, Ajax already belongs to the old technology, and now almost no one will use, here is mainly the bottom of the things to share with you, in case of loading the interviewer.



Ajax, "Asynchronous JavaScript and XML" (Asynchronous JavaScript and XML), refers to a web development technique that creates interactive Web applications.



AJAX enables Web pages to be updated asynchronously by exchanging small amounts of data in the background with the server. This means that you can update a part of a webpage without reloading the entire page.



The origin of Ajax



The technology was applied around the 1998.



The first component that allows client script to send HTTP requests (XMLHTTP) is written by the Outlook Web Access team. The component was originally part of Microsoft Exchange Server and quickly became an internet Explorer 4.0[3]. Some observers believe that Outlook Web access is the first successful business application that has AJAX technology applied and is the leader of many products, including Oddpost's webmail products.



But it's Google that really makes Ajax known to the public.



Google uses asynchronous communications in its famous interactive apps, such as Google discussion groups, Google Maps, Google search suggestions, Gmail, and more. The word Ajax was created by the ajax:a New approach to WEB applications, and the rapid spread of the article increased the awareness of people using the technology. In addition, support for Mozilla/gecko has made the technology more sophisticated and easier to use.



The principle of Ajax



Ajax works by adding a middle-tier (Ajax engine) between the user and the server, making the user operation asynchronous with the server response. Not all user requests are submitted to the server, such as data validation and processing, to be done by the Ajax engine itself, only to determine the need to read new data from the server and then by the Ajax engine to submit the request to the server.



Ajax has the core of JavaScript, XMLHttpRequest, Dom objects, through the XMLHttpRequest object to send an asynchronous request to the server, from the server to  and then use JavaScript to manipulate the DOM and update the page. One of the most critical steps is getting the request data from the server.



Let's take a look at these few objects:



1) XMLHttpRequest Object



One of the biggest features of Ajax is that it is possible to transfer or read and write data to the server without refreshing the page (also known as no Refresh Update page), which is mainly due to the XMLHTTP component XMLHttpRequest object.






XMLHttpRequest Object Method Description:






2) JavaScript



The language of the front-end most fried days.



3) DOM Document Object Model



The DOM is a set of APIs that are used for HTML and XML files. It provides a structural representation of the file, allowing you to change the contents and the visible objects. The essence is to establish a bridge between Web pages and script or program language. The properties, methods, and events that all Web developers can manipulate and create files are represented by objects (for example, document represents the "file itself" pair, the Table object represents the HTML table object, and so on). (Want to see more on the Topic.alibabacloud.comAJAX Development Manual section of the study)



These objects can be used by most of today's browsers as script. A Web page built with HTML or XHTML can also be thought of as a set of structured data that is enclosed in the DOM (Document object Model), which provides read and write support for individual objects in a Web page.



4) XML



The Extensible Markup Language (extensible Markup Language) has an open, extensible, self-describing language structure that has become the standard for data and document transmission on the web and is used by other applications to exchange data.



5) Comprehensive



The Ajax engine, in effect, is a more complex JavaScript application that handles user requests, reads and writes to the server, and changes DOM content.



JavaScript's Ajax engine reads the information and interactively rewrites the DOM, which allows the Web page to be reconstructed seamlessly, that is, after the page has been downloaded to change the content of the page, which we have been using JavaScript and Dom in a widely used way, but to make the Web page really dynamic up, Not only the internal interaction, but also the need to  from the outside, in the past, we have to let users enter data and through the DOM to change the content of the Web page, but now, XMLHttpRequest, we can not overload the page to read and write data on the server, so that the user's input to a minimum.



Ajax separates the interface in the Web from the application (or the separation of data from the presentation), and in the past there is no clear boundary between the separation of data and presentation, which facilitates division of labor, reduces web application errors caused by non-technical changes to the page, improves efficiency, It is also more applicable to the current release system. It is also possible to pass on some of the previous server workloads to the client, which facilitates the client's ability to handle idle processing.



The advantages of Ajax



The traditional Web application interaction is triggered by the user to trigger an HTTP request to the server after the server has processed it and then returns a new HTML page to the client.



Each time the server processes a client-submitted request, the client can only wait and, even if it is only a small interaction, to get a very simple data from the server side, return a full HTML page, and each time the user spends a waste of his or her bandwidth to reread the entire page.



This practice wastes a lot of bandwidth, and the response time of the application depends on the response time of the server, because each application's interaction needs to send a request to the server. This causes the user interface to respond much more slowly than the local application.



Unlike this, an AJAX application can send and retrieve only the necessary data to the server, using SOAP or some other XML-based Web service interface, and using JavaScript on the client to process the response from the server.



Because the amount of data exchanged between the server and the browser is much reduced, the result is that we can see applications that respond faster. At the same time, a lot of processing can be done on the client machine making the request, so the processing time of the Web server is also reduced.



In fact, I do not have to brush the entire page to see the changes, change more quickly, the client shared the server's work, the server pressure is even smaller.



The disadvantage of Ajax



Data, interface leaks, security is not very good.



This is the end of this article (want to see more on the Topic.alibabacloud.comAJAX User manual section of the study), there are questions can be in the message below the question.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.