Simply talk about Ajax core objects _ajax related

Source: Internet
Author: User
Tags http request

Ajax was a new technology that was born in the February 2005 but is now hot. This new technology can greatly improve the user experience of the site.

What is Ajax

Ajax is an English abbreviation for asynchronous JavaScript and XML (asynchronous JavaScript and XML).

The core idea of Ajax is to send an asynchronous request using a XMLHttpRequest object. Ajax is not a new language or technology, it is actually a number of technologies are grouped together in a certain way, to play their role in a common collaboration.

The advantages of Ajax

1. Reduce the burden on the server. The principle of Ajax is "data on demand".

2. No need to refresh the page, reduce the user's psychological and actual waiting time.

3. Bring a better user experience.

4. Some of the work of the server can be transferred to the client, the use of the client idle capacity to deal with, reduce server burden, make full use of broadband resources, save space and broadband rental costs.

5. External data can be invoked.

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

7. Further promote page rendering and data separation.

Two. Introduction of XMLHttpRequest Objects

One of the biggest features of Ajax is the fact that you can transfer or read or write data to the server without refreshing the page (also known as no Refresh Update page), which is mainly thanks to the XMLHTTP component XMLHttpRequest object.

XMLHttpRequest Property

Properties of the XMLHttpRequest object

Property

Describe

onReadyStateChange

This event handler is triggered when each state changes, and typically a JavaScript function is invoked
ReadyState Status of the request
ResponseText The response of the server, expressed as a string
Responsexml The response of the server, expressed as XML, that can be resolved to a DOM object
Status HTTP status of the server
StatusText Corresponding text for HTTP status

This event handler is triggered when each state changes, and typically a JavaScript function is invoked

XMLHttpRequest method

Some common methods of XMLHttpRequest objects

Method Describe
Abort () Stop current request
getAllResponseHeaders () Returns all the corresponding headers of an HTTP request as a key/value pair
getResponseHeader ("header") Returns the string value of the specified header
Open ("Method", "url") Establish a call to the server. The method parameter can be get,post or put, and the URL parameter can be a relative URL or an absolute URL. This approach also includes 3 optional parameters
Send (content) Send a request to the server
setRequestHeader ("header", "value") Sets the specified header to the supplied value and must first call the open () method before any header is set

Related Article

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.