Ajax stands for asynchronous javaspt and XML.
1. Why Ajax?
In general, the interaction between web programs and servers is: the page sends a request waiting for processing by the server, the server processes data, and the user page refreshes the entire page, thus completing an interaction.
If this synchronization method is used for multiple interactions between such pages and the server, the user will need a lot of time to wait for the server to process.
The idea of Ajax asynchronous processing is: when a page sends a request, it is handed over to the server for processing. When the server processes the request, the page does not have to wait for other operations. After the server completes processing, the result is displayed on the current page. You do not need to refresh the entire page.
2. Simple Ajax implementation
To implement Ajax, you need to use the XMLHTTPRequest object of JavaScript.
Implementation Process
1) create an object (different browsers have different creation methods. Generally, you need to consider IE and non-ie browsers)
The Internet Explorer uses activexobject.
You can directly create an XMLHTTPRequest object instance in a non-IE browser.
2) send a request.
Before sending a request, you must establish a connection with the server. It requires parameters such as the sending type, connection URL, and asynchronous connection status value.
> Sending type: Get/post.
> URL: Connection address +? + Transfer value (+ & + transfer value...) [The get method is used here]
> Asynchronous connection status value: True/false. The default value is true. True indicates an asynchronous connection.
Before sending a request, you must create a return function to specify the content to be executed after the server responds.
Send a request.
3) Server Response Functions
3. A simple instance
<! Doctype HTML>