Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the attribute meaning of onreadystatechange in Aajx

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail what the attribute meaning of onreadystatechange in Aajx is. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

The attribute meaning of onreadystatechange in Aajx

The readyState property holds the state of the XMLHttpRequest.

The onreadystatechange attribute defines the function to execute when the readyState changes.

The status and statusText properties store the state of the XMLHttpRequest object.

Attribute description

Onreadystatechange defines the function to be called when the readyState property changes.

ReadyState

The state of XMLHttpRequest is saved.

0: request is not initialized

1: the server connection has been established

2: the request has been received

3: processing request

4: request completed and response ready

Status

"OK"

"Forbidden"

"Page not found"

For a complete list, please visit the Http message reference manual

StatusText returns status text (such as "OK" or "Not Found")

The onreadystatechange function is called whenever the readyState changes.

When readyState is 4 and status is 200, the response is ready:

Example

Function loadDoc () {

Var xhttp = new XMLHttpRequest ()

Xhttp.onreadystatechange = function () {

If (this.readyState = = 4 & & this.status = = 200) {

Document.getElementById ("demo") [xss_clean] =

This.responseText

}

}

Xhttp.open ("GET", "ajax_info.txt", true)

Xhttp.send ()

}

Note: onreadystatechange is triggered five times (0-4), and each time the readyState changes.

This is the end of this article on "what is the attribute meaning of onreadystatechange in Aajx". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report