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: