Javascript Study Notes (7) Ajax and Http status code _ basic knowledge

Source: Internet
Author: User
This article mainly introduces Ajax and Http status codes in javascript, which are very simple and practical. If you need them, refer Ajax and its working principles

AJAX is a technology that exchanges data with servers without Refreshing Web pages. It was first used by Google in Google Maps and quickly became popular.

AJAX cannot be cross-origin. To cross-origin, you can use document. domain = 'a. com'; or use the server proxy to proxy the XMLHttpRequest file.

AJAX is based on existing Internet standards and is used together:

XMLHttpRequest object (asynchronously exchanging data with the server)
JavaScript/DOM (Information Display/interaction)
CSS (define a style for data)
XML (as the format for converting data)

Create an XMLHttpRequest object

All modern browsers (IE7 +, Firefox, Chrome, Safari, and Opera) have built-in XMLHttpRequest objects.

Create an Ajax object:

// IE6 or above
Var oAjax = new XMLHttpRequest ();

// IE6
Var oAjax = new ActiveXObject ("Microsoft. XMLHTTP ")
Connect to the server

OAjax. open (method, url, asynchronous or not)
We all know that Ajax, that is, "Asynchronous Javascript And XML" (Asynchronous JavaScript And XML), is a web page development technology that creates interactive web applications. Therefore, Ajax is inherently working in asynchronous mode (Asynchronous is true, synchronous is false)

Synchronous and asynchronous

Synchronization refers to the communication mode in which the sender sends a packet only after the receiver sends a response.
Asynchronous means that the sender sends the next packet instead of sending the response from the receiver.
(To put it simply, synchronization can only do one thing, while Asynchronization can do multiple things at the same time)

Send request send ()

The Code is as follows:


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.