[ajax Learning notes] Ajax Preliminary interview

Source: Internet
Author: User

The AJAX full name is: asynchronous Javasctipt and Xml.

1. Why do I need ajax?

The general Web program interacts with the Server: the page sends the request waiting for the server to process, and the server processes the Data. The user page refreshes the entire page. Thus completing an Interaction.

It is assumed that such a synchronous way of interacting with the server multiple Times. Users will need a lot of time to wait for the server to Process.

The idea of Ajax asynchronous processing is that when a page sends a Request. Given to server processing, the same time that the server processes, the page does not have to wait for other operations, when the server is finished Processing. Displays the results on the current Page. No need to refresh the entire page.

Simple implementation of 2.ajax

Implementing AJAX requires the use of Javascript's XMLHttpRequest Object.

Implementation process

1) Create objects (different browsers have different methods of creation, generally need to consider IE and Non-ie browser)

IE browser to use the Activexobject.

Non-ie browsers can create a new XMLHttpRequest object instance Directly.

2) Send the Request.

You need to establish a connection to the server before sending the Request. The number of parameters it requires is the sending type, the URL of the connection, the asynchronous connection state value, and so On.

> Send type: get/post and so On.

> Url: Connection Address +? + Transferred value (+ & + Transferred value): ) [here is the Get method used]

> Asynchronous Connection Status Value: true/false. The default is True. True indicates an asynchronous Connection.

A return function is also established before sending the request, which is used to specify what to run after the server Response.

Send the Request.

3) Server response function

3. A simple example

<! DOCTYPE Html>


[ajax Learning notes] Ajax Preliminary interview

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.