Get Http Error
Contents |
sections of messages Error, Forward and redirection responses may be used to contain human-readable diagnostic information. Success 2xx These codes indicate success. The body section if present http status code 400 is the object returned by the request. It is a MIME format object. It
Http Response Example
is in MIME format, and may only be in text/plain, text/html or one fo the formats specified as acceptable in http code 302 the request. OK 200 The request was fulfilled. CREATED 201 Following a POST command, this indicates success, but the textual part of the response line indicates the URI by which the newly created
Http 404
document should be known. Accepted 202 The request has been accepted for processing, but the processing has not been completed. The request may or may not eventually be acted upon, as it may be disallowed when processing actually takes place. there is no facility for status returns from asynchronous operations such as this. Partial Information 203 When received in the response to a GET command, this http 403 indicates that the returned metainformation is not a definitive set of the object from a server with a copy of the object, but is from a private overlaid web. This may include annotation information about the object, for example. No Response 204 Server has received the request but there is no information to send back, and the client should stay in the same document view. This is mainly to allow input for scripts without changing the document at the same time. Error 4xx, 5xx The 4xx codes are intended for cases in which the client seems to have erred, and the 5xx codes for the cases in which the server is aware that the server has erred. It is impossible to distinguish these cases in general, so the difference is only informational. The body section may contain a document describing the error in human readable form. The document is in MIME format, and may only be in text/plain, text/html or one for the formats specified as acceptable in the request. Bad request 400 The request had bad syntax or was inherently impossible to be satisfied. Unauthorized 401 The parameter to this message gives a specification of authorization scheme
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the
Http 422
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions
Http 502
Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million http status codes cheat sheet programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How do I get HTTP error response code in Jquery POST up vote 7 down vote favorite I have a https://www.w3.org/Protocols/HTTP/HTRESP.html wrapper function used to send requests to a server, I need to do something specific if the server returns a code of 401 and I'm not sure how to get this data $.mobile.showPageLoadingMsg(); $.post(apiUrl+method,p,function(d) { $.mobile.hidePageLoadingMsg(); console.log(d.success); console.log(d.message); if(d.success == true){ window[callback](d.data); } else{ if(d.message != null){ alert(d.message); } } },'json') .error(function() { //need to check for 401 status here to do something $.mobile.hidePageLoadingMsg(); alert("error"); }); If my server side code throws a http://stackoverflow.com/questions/8513295/how-do-i-get-http-error-response-code-in-jquery-post 401 exception the jquery .error function picks this up just because its not 200 OK but I need to check if its a 401 code. javascript jquery jquery-mobile jquery-post share|improve this question edited Dec 14 '11 at 23:48 comu 535722 asked Dec 14 '11 at 23:38 Brian 2,11274181 === not ==, like wise for !== != :) –Sam Oct 13 '14 at 10:00 add a comment| 1 Answer 1 active oldest votes up vote 10 down vote accepted In the error callback, check xhr.status where xhr is the first argument to the function. share|improve this answer answered Dec 14 '11 at 23:41 alex 267k128651806 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged javascript jquery jquery-mobile jquery-post or ask your own question. asked 4 years ago viewed 3993 times active 4 years ago Linked -1 How can I get response status of a jquery POST command? Related 4944How to check if an element is hidden in jQuery?5667How to redirect
referer DNT X-Forwarded-For Status codes 301 Moved Permanently 302 Found 303 See Other 403 Forbidden 404 Not Found 451 Unavailable For Legal Reasons v t e This is a list of Hypertext Transfer Protocol (HTTP) https://en.wikipedia.org/wiki/List_of_HTTP_status_codes response status codes. It includes codes from IETF internet standards, other IETF RFCs, other specifications, and some additional commonly used codes. The first digit of the status code specifies one of five classes of response; an HTTP client must recognise these five classes at a minimum. The phrases used are the standard wordings, but any human-readable alternative can be provided. Unless otherwise stated, the status code is part of http status the HTTP/1.1 standard (RFC 7231).[1] The Internet Assigned Numbers Authority (IANA) maintains the official registry of HTTP status codes.[2] Microsoft IIS sometimes uses additional decimal sub-codes to provide more specific information,[3] but not all of those are here (note that these sub-codes only appear in the response payload and in documentation; not in the place of an actual HTTP status code). Contents 1 1xx Informational 2 2xx Success 3 3xx http status code Redirection 4 4xx Client Error 5 5xx Server Error 6 Unofficial codes 6.1 Internet Information Services 6.2 nginx 6.3 Cloudflare 7 See also 8 Notes 9 References 10 External links 1xx Informational[edit] Request received, continuing process. This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty line. Since HTTP/1.0 did not define any 1xx status codes, servers must not[note 1] send a 1xx response to an HTTP/1.0 client except under experimental conditions.[4] 100 Continue The server has received the request headers and the client should proceed to send the request body (in the case of a request for which a body needs to be sent; for example, a POST request). Sending a large request body to a server after a request has been rejected for inappropriate headers would be inefficient. To have a server check the request's headers, a client must send Expect: 100-continue as a header in its initial request and receive a 100 Continue status code in response before sending the body. The response 417 Expectation Failed indicates the request should not be continued.[2] 101 Switching Protocols The requester has asked the server to switch protocols and the server has agr