[Ajax Study Notes] Ajax preliminary test

Source: Internet
Author: User

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> 

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.