The principle of AJAX is that the foreground data is transmitted to the background through the XMLHTTP object through javascript. After receiving the request, the background transmits the desired result to the foreground, in this way, page sending is not required, pages are data transferred back and forth, and page refreshing is implemented.
The principle of AJAX is simply to send an asynchronous request to the server through the XMLHTTPRequest object, obtain data from the server, and then use JavaScript to operate the Dom to update the page.
The most critical step is to obtain request data from the server. To understand the process and principles, we must understand XMLHttpRequest.
We can see that the XMLHTTPRequest object is completely used to send a request to the server, and its role is also limited to this, but its role is the key to the entire Ajax implementation, we can regard the server as a data interface, which returns a plain text stream. Of course, this text stream can be in XML format, HTML, or Javascript CodeOr a string. At this time, XMLHttpRequest requests this page from the server, and the server writes the text results to the page. This is the same as the normal Web development process, after the client asynchronously obtains this result, it is not directly displayed on the page, but processed by JavaScript first and then displayed on the page.
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.