問題描述
當我在我們的生產系統上執行 XHR 時,響應中的 statusText
將是一個空字符串.但是,在我們的開發系統中,statusText
會正確反映狀態.
When I perform an XHR on our production system, the statusText
in the response will be an empty string. However, on our development system, the statusText
will reflect the status correctly.
根據 XMLHttpRequest.statusText<的文檔/code>,它只能在處理請求時為空.但是,我在
onload
處理程序中看到了這種行為.
According to the documentation for XMLHttpRequest.statusText
, it should only be empty while the request is being processed. However, I am seeing this behavior in the onload
handler.
此外,這種行為只能在 Chrome 和 Edge 中觀察到.Firefox 將顯示正確的文本.
Additionally, this behavior can only be observed in Chrome and Edge. Firefox will display the correct text.
那么,statusText
的內容究竟是如何確定的呢?
So, how is the content of the statusText
actually determined?
推薦答案
可能是因為一臺服務器使用 HTTP/2,而另一臺沒有.HTTP/2 不再有原因短語.
It might be because one server uses HTTP/2, while the other does not. HTTP/2 doesn't have reason phrases anymore.
這篇關于為什么我的 XHR 的 statusText 是空的?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!