为什么我的 XHR 的 statusText 是空的? [英] Why is the statusText of my XHR empty?

查看:14
本文介绍了为什么我的 XHR 的 statusText 是空的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在我们的生产系统上执行 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 是空的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆