本文介绍了XMLHttpRequest 中不同的就绪状态是什么意思,我该如何使用它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
XMLHttpRequest
有 5 个 readyState
,我只用了其中的 1 个(最后一个,4
).
XMLHttpRequest
has 5 readyState
s, and I only use 1 of them (the last one, 4
).
其他的有什么用,我可以在哪些实际应用中使用它们?
What are the others for, and what practical applications can I use them in?
推荐答案
readyState
值的完整列表是:
State Description
0 The request is not initialized
1 The request has been set up
2 The request has been sent
3 The request is in process
4 The request is complete
(来自 https://www.w3schools.com/js/js_ajax_http_response.asp)
在实践中,除了 4 个之外,你几乎从不使用它们中的任何一个.
In practice you almost never use any of them except for 4.
某些 XMLHttpRequest 实现可能会让您在 readyState==3
时在 responseText
中看到部分收到的响应,但这并不是普遍支持的,并且不应该依赖.
Some XMLHttpRequest implementations may let you see partially received responses in responseText
when readyState==3
, but this isn't universally supported and shouldn't be relied upon.
这篇关于XMLHttpRequest 中不同的就绪状态是什么意思,我该如何使用它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!