What are the possible values for `jqXHR.status`?
Solution 1
It can be anything found here.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
The status
value is the HTTP protocol status field that http servers send on the response.
Note at this point, the jquery ajax documentation indicates that status
is deprecated, and you should use statusCode
instead.
Solution 2
According to the jQuery API Documentation:
For backward compatibility with
XMLHttpRequest
, ajqXHR
object will expose the following properties and methods:(...)
status
statusText
You can then read more about the XMLHttpRequest
object on its WHATWG Living Standard page or on its page at at MDN or at W3Schools. The latter also provides a link to a list of HTTP Status Messages.
Note that jqXHR
also exposes XMLHttpRequest
's statusText
attribute which can be used to get a quick and useful error message in addition to the status code.
Nate Pet
Updated on January 09, 2020Comments
-
Nate Pet over 4 years
What are the possible values for
jqXHR.status
?So far, I can see the following:
if (jqXHR.status === 0) { msg = 'Network Problem'; } else if (jqXHR.status == 404) { msg = 'Requested page not found. [404]'; } else if (jqXHR.status == 500) { msg = 'Internal Server Error [500].'; }
-
ryan over 11 yearsIt doesn't say anywhere that status is deprecated
-
rep_movsd over 9 yearsIn fact statusCode is a methid to pass callbacks to for each type of error you want to handle