简体   繁体   English

哪些 HTTP 状态代码会在 XMLHttpRequest 上触发错误事件

[英]What HTTP status codes fire error event on XMLHttpRequest

I've read every spec I can find, even the W3 for ProgressEvents as well as XMLHttpRequest , and I'm finding diddly regarding WHICH status codes (or What response) fire an Error event on an async XHR request.我已经阅读了我能找到的所有规范,甚至是 W3 的 ProgressEvents 和XMLHttpRequest ,我发现关于哪个状态代码(或什么响应)在异步 XHR 请求上触发 Error 事件的问题。 The most I can find is references to checking the status code itself on the object and handling that, which normally treats anything but 200 as an Error, yet a 3xx redirect from, say, a POST is not an Error (I can't recall if the XHR will follow a redirect automatically) Can someone help me out or point me in the right direction regarding the spec (no libraries) for all responses that initiate an onerror event?我能找到的最多的是检查对象上的状态代码本身并处理它的引用,它通常将 200 以外的任何内容都视为错误,但来自 POST 的 3xx 重定向不是错误(我不记得了如果 XHR 将自动跟随重定向)有人可以帮助我或为我指出有关规范(无库)的正确方向,用于启动onerror事件的所有响应?

onerror only fires for network-level events, which means that onload will fire if there is a successful response, regardless of HTTP status code. onerror仅针对网络级事件触发,这意味着如果有成功响应,则无论 HTTP 状态代码如何, onload都会触发。 See this question for more discussion: When should XMLHttpRequest's onerror handler fire有关更多讨论,请参阅此问题: 何时应触发 XMLHttpRequest 的 onerror 处理程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM