The code above contains detailed notes, and the principle of ajax is simple and, in general, sends data using xmlttprequest objects. Here's an additional description of the subject。
The code uses many boolean expression short-circuit features instead of conditional statements, and good use of boolean short-circuit features allows a large number of simple conditional statements to be simplified. - yeah
Basic properties of xmlttprequest objects

Readystate properties have five state values:
0: uninitiated: not initialized. Xmlttprequest objects have been created but not initialized。
One is loating: i'm ready to send。
2: loeded, sent but no response received。

3: it's interactive: receiving response, but not yet。
4: completed: response accepted。
Responsetext: response text returned by the server. Only when readystate > = 3. When readystate=3, the returned response text is incomplete and only readystate=4 received the complete response text. Responsexml: response information is xml and can be parsed as dom object. Status: the http status code for the server, if 200, is ok, 404, indicating that it was not found. Statustext: the text of the server's http status code. Ok, not found。
Basic method for xmlttprequest object

Open (method, url, asyn): open xmlhttprequest object. Among them, the method method is get, post,delete, put. Url is the address where resources are requested. The third parameter indicates whether or not a step is used. The default situation is true, because ajax is characterized by a walk-through. If you use sync, false. Send (body): send request ajax. The content to be sent can be the required parameters, and if not, directly send (null)
Use method
Directly calls the ajax function as defined above and transmits the corresponding options and parameters。




