Reputation: 20337
I have a jQuery AJAX post request that is unexpectedly triggering the error
callback instead of success
. One random suspicion I have is the 302 status code it is receiving, although that may be wrong.
I looked at the documentation, but I feel like one thing is a bit unclear: What is jQuery's definition of a successful request?
Upvotes: 9
Views: 2061
Reputation: 95059
If the response is between 199 and 300 ( >= 200 and < 300 ) or equal to 304 and the responseText can be successfully converted to the dataType that you provide (text by default), it is considered a successful request.
For example, if you return JSON and you get a 200 response status but it fails, it is more than likely a JSON parser problem meaning your JSON is not valid.
If you are returning HTML or XML and it fails with a 200 response status, the responsetext couldn't be converted to HTML or XML respectively (commonly happens in IE with invalid html/xml)
Upvotes: 8