Home > Web Front-end > JS Tutorial > body text

How to write native Ajax

(*-*)浩
Release: 2020-09-08 16:18:20
Original
11209 people have browsed it

How to write native Ajax: first create an XMLHttpRequest object; then write the callback function onreadystatechange; then configure the request information; and finally send the request.

How to write native Ajax

Ajax (abbreviation for Asynchronous JavaScript and XML) is a web development technology that requests data asynchronously, which is very helpful for improving user experience and page performance.

Simply put, Ajax loads background data through asynchronous requests and renders it on the web page without reloading the page. Common application scenarios include form verification to log in or not. Successful entry, Baidu search drop-down box prompts, express delivery tracking number query, etc.

If you want to have a comprehensive understanding of Ajax, you can go to Js Tutorial to have a comprehensive understanding of it.

Now Ajax has become very convenient after various optimizations. For example, using Jquery only requires one line to use Ajax.

How to write native Ajax

#So what does native Ajax look like?

Let’s take a look.

 
Copy after login

readystate:

The state of XMLHttpRequest is stored. Changes from 0 to 4.

0: The request is not initialized

1: The server connection has been established

2: The request has been received

3: The request is being processed

4: Request completed and response ready

status:

200: "OK"

404: Page not found

405: Request Incorrect method

500: Server internal error

403: Request forbidden

Ajax has two request methods:

get request method

Copy after login

post request method

Copy after login

The above is the detailed content of How to write native Ajax. 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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!