What are all the xhr states that jquery accepts as success states? Similarly what are the error states? I know 200 is a success state and 401 is an error state. 开发者_如何学JAVAAny further information on this could be helpful. Can someone please point me to a good read. I could not get the information from jquery api.
When I can't find an answer in the docs, I dive into the source. Here's the bit you're looking for, specifically line 2:
// If successful, handle type chaining
if ( status >= 200 && status < 300 || status === 304 ) {
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
if ( s.ifModified ) {
if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
jQuery.lastModified[ ifModifiedKey ] = lastModified;
}
if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
jQuery.etag[ ifModifiedKey ] = etag;
}
}
// If not modified
if ( status === 304 ) {
statusText = "notmodified";
isSuccess = true;
// If we have data
} else {
try {
success = ajaxConvert( s, response );
statusText = "success";
isSuccess = true;
} catch(e) {
// We have a parsererror
statusText = "parsererror";
error = e;
}
}
} else {
// We extract error from statusText
// then normalize statusText and status for non-aborts
error = statusText;
if( !statusText || status ) {
statusText = "error";
if ( status < 0 ) {
status = 0;
}
}
}
http://docs.jquery.com/Ajax_Events this will be a help
I just googled,
how about this
http://www.w3.org/TR/XMLHttpRequest/
精彩评论