简体   繁体   English

从AJAX请求收到HTTP错误时,textStatus是什么?

[英]What is textStatus when an HTTP error is received from an AJAX request?

In jQuery, when an AJAX request fails due to an HTTP error (eg, 500 Internal Server Error) what is the value of the textStatus argument to the error handler? 在jQuery中,当AJAX请求由于HTTP错误(例如500 Internal Server Error)而失败时,错误处理程序的textStatus参数值是多少? Eg, 例如,

$.ajax(...).fail(function(jqXHR, textStatus, errorThrown) {
    console.log(textStatus); // What is this when an HTTP error occurs?
});

The jQuery documentation for $.ajax() simply lists the possible values, but there is no clear explanation as to when they occur. $ .ajax()的jQuery文档仅列出了可能的值,但没有明确说明何时出现这些值。 Particularly, jQuery mentions: jQuery特别提到:

When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." 发生HTTP错误时, errorThrown会接收HTTP状态的文本部分,例如“未找到”或“内部服务器错误”。

But it does not say what the value of textStatus will be. 但这并没有说明textStatus的值是什么。

When you receive an HTTP error response (eg, 500 Internal Server Error), the value of the textStatus argument will be "error" . 当您收到HTTP错误响应(例如500 Internal Server Error)时, textStatus参数的值将为"error" This was determined through testing. 这是通过测试确定的。

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

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