Home > Web Front-end > JS Tutorial > How to learn ajax well? The only way to learn ajax (classic)

How to learn ajax well? The only way to learn ajax (classic)

寻∝梦
Release: 2018-09-10 15:09:34
Original
3018 people have browsed it

This article mainly introduces the learning path of ajax, how to learn ajax well, and the learning of ajax must be experienced. Let us take a look at this article now

Ajax (Asynchronous JavaScript and XML)

Before learning Ajax, you must have the foundation of JavaScript and DOM

1. Introduction and advantages of Ajax

a . What is Ajax?

Ajax uses an asynchronous interactive process

1. Partial refresh

2. Fetch data on demand

b. Advantages of Ajax Disadvantages

c. Application of Ajax

2. Create an Ajax object. This is the first step in learning Ajax

var request=new XMLHttpRequest();

var d=new Date();

The process of creating an object is a bit more complicated, but these codes are fixed

Write the process of creating an XMLHttpRequest object into a function

Mainly divides browsers into two types

One is IE series browsers (IE5.0 IE5.5 IE6.0, IE7 IE8)

One is non-IE browsers (Both are based on W3C standards) FF Mozilla NetScape (If you want to know more, go to the PHP Chinese website AJAX Development Manual column to learn)

3. Use Ajax to request the server

4. Obtain the data sent by the server through Ajax

5. Create an Ajax class to simplify the use of Ajax

6. Ajax instance production (unique checksum and no refresh paging)

new ActiveXObject("Microsoft.XMLHTTP");

new ActiveXObject("MSXML.XMLHTTP");

new ActiveXObject("'Msxml2.XMLHTTP.7.0'");

....

['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP']

Methods in the Ajax engine object

abort() Stop the current request

getAllResponseHeaders() Return the complete headers as a string

getResponseHeader("headerLabel") Return a single header label as a string

open("method","URL"[,asyncFlag[,"userName" [, "password"]]]) Set the target URL, method, and other parameters of the pending request

send(content) Send the request

setRequestHeader("label", "value") Set the header and send it with the request

Attributes in the Ajax engine object

onreadystatechange event trigger for state change

readyState object state (integer):

0 = Uninitialized 1 = Reading 2 = Read 3 = Interactive 4 = Completed

responseText The text version of the data returned by the server process

responseXML The DOM-compatible XML document of the data returned by the server process Object

status Status code returned by the server, such as: 404 = "File not found", 200 = "Success"

statusText Status text information returned by the server

This article The article ends here (if you want to see more, go to the PHP Chinese website AJAX User Manual column to learn). If you have any questions, you can leave a message below.

The above is the detailed content of How to learn ajax well? The only way to learn ajax (classic). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template