Home >Web Front-end >JS Tutorial >What does Ajax mean? How to use Ajax?

What does Ajax mean? How to use Ajax?

不言
不言Original
2018-10-11 09:58:3116365browse

When we learn web development, we may often hear the name Ajax. So, what does ajax mean? How can it be used? This article will tell you about the meaning of ajax and how to use ajax. Interested friends can take a look.

What does Ajax mean?

ajax is the abbreviation of Asynchronous JavaScript and XML (asynchronous JavaScript and XML technology), which refers to a web development technology for creating interactive web applications;

ajax Not a new programming language, but a new way of using existing standards.

ajax is a technology used to create fast dynamic web pages. By exchanging small amounts of data with the server in the background. Ajax allows web pages to be updated asynchronously. This means that parts of a web page can be updated without reloading the entire page. If traditional web pages (which do not use ajax) need to update content, the entire web page must be reloaded.

After reading the meaning of ajax above, let’s briefly take a look at the advantages and disadvantages of ajax.

Advantages of ajax:

1. The biggest point is that the page does not refresh, and the user experience is very good.

2. Use asynchronous mode to communicate with the server, with faster response capability. .

3. Some of the work previously burdened by the server can be transferred to the client, using the idle capacity of the client to process it, reducing the burden on the server and bandwidth, and saving space and broadband rental costs. And to reduce the burden on the server, the principle of ajax is to "fetch data on demand", which can minimize the burden on the server caused by redundant requests and responses.

4. Based on standardized and widely supported technology, there is no need to download plug-ins or small programs.

5. Ajax can make Internet applications smaller, faster, and more friendly.

Disadvantages of ajax:

1. Ajax does not support the browser back button.

2. Security issues AJAX exposes the details of interaction with the server.

3. The support for search engines is relatively weak.

4. Destroyed the exception mechanism of the program.

5. It is not easy to debug.

After understanding What does Ajax mean, let’s take a look at How to use ajax?

First of all, we need to know that Ajax uses JS to initiate a request and get the content returned by the server. The biggest difference between this and previous technology is that the page is not refreshed, which improves the user experience. In short, ajax is mainly used to request data from the backend of the server in the front-end page. Since ajax is used to request data, how to send an ajax request? Here are five steps to take a look at.

1. Create an object XMLHttpRequest

var xhr = new XMLHttpRequest(); In order to support ie6 and earlier versions, var xhr=new ActiveXObject()

2 , Monitor the status changes after the request is successful

3. Set the request parameters

4. Initiate the request

5. Manipulate the DOM to achieve dynamic partial refresh

The above is the entire content of this article. For more exciting content, you can pay attention to the php Chinese website! ! !

The above is the detailed content of What does Ajax mean? How to use Ajax?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn