XMLHttpRequest
有 5 个 readyState
,我只用了其中的一个(最后一个,4
)。
其他的有什么用,我可以在哪些实际应用中使用它们?
最佳答案
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 个之外,您几乎从不使用它们中的任何一个。
一些 XMLHttpRequest 实现可能会让您在 readyState==3
时在 responseText
中看到部分收到的响应,但这并未得到普遍支持,并且不应依赖。
关于javascript - XMLHttpRequest 中的不同就绪状态是什么意思,我该如何使用它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/632774/