public/js/app.js
// Callback for when everything is done
Callback for when everything is done
Callback for when everything is done
function done( status, nativeStatusText, responses, headers ) {
			var isSuccess, success, error, response, modified,
			statusText = nativeStatusText;
			if ( completed ) {
				return;
			}
			completed = true;
			if ( timeoutTimer ) {
				window.clearTimeout( timeoutTimer );
			}
			transport = undefined;
			responseHeadersString = headers || "";
			jqXHR.readyState = status > 0 ? 4 : 0;
			isSuccess = status >= 200 && status < 300 || status === 304;
			if ( responses ) {
				response = ajaxHandleResponses( s, jqXHR, responses );
			}
			response = ajaxConvert( s, response, jqXHR, isSuccess );
			if ( isSuccess ) {
				if ( s.ifModified ) {
					modified = jqXHR.getResponseHeader( "Last-Modified" );
					if ( modified ) {
						jQuery.lastModified[ cacheURL ] = modified;
					}
					modified = jqXHR.getResponseHeader( "etag" );
					if ( modified ) {
						jQuery.etag[ cacheURL ] = modified;
					}
				}
				if ( status === 204 || s.type === "HEAD" ) {
					statusText = "nocontent";
			} else if ( status === 304 ) {
				statusText = "notmodified";
			} else {
				statusText = response.state;
				success = response.data;
				error = response.error;
				isSuccess = !error;
			}
		} else {
				error = statusText;
				if ( status || !statusText ) {
					statusText = "error";
					if ( status < 0 ) {
						status = 0;
					}
				}
			}
			jqXHR.status = status;
			jqXHR.statusText = ( nativeStatusText || statusText ) + "";
			if ( isSuccess ) {
				deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
			} else {
				deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
			}
			jqXHR.statusCode( statusCode );
			statusCode = undefined;
			if ( fireGlobals ) {
				globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
					[ jqXHR, s, isSuccess ? success : error ] );
			}
			completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
			if ( fireGlobals ) {
				globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
				if ( !( --jQuery.active ) ) {
					jQuery.event.trigger( "ajaxStop" );
				}
			}
		}
function done ( status , nativeStatusText , responses , headers ) { var isSuccess , success , error , response , modified , statusText = nativeStatusText ; if ( completed ) { return ; } completed = true ; if ( timeoutTimer ) { window . clearTimeout ( timeoutTimer ) ; } transport = undefined ; responseHeadersString = headers || "" ; jqXHR . readyState = status > 0 ? 4 : 0 ; isSuccess = status >= 200 && status < 300 || status === 304 ; if ( responses ) { response = ajaxHandleResponses ( s , jqXHR , responses ) ; } response = ajaxConvert ( s , response , jqXHR , isSuccess ) ; if ( isSuccess ) { if ( s . ifModified ) { modified = jqXHR . getResponseHeader ( "Last-Modified" ) ; if ( modified ) { jQuery . lastModified [ cacheURL ] = modified ; } modified = jqXHR . getResponseHeader ( "etag" ) ; if ( modified ) { jQuery . etag [ cacheURL ] = modified ; } } if ( status === 204 || s . type === "HEAD" ) { statusText = "nocontent" ; } else if ( status === 304 ) { statusText = "notmodified" ; } else { statusText = response . state ; success = response . data ; error = response . error ; isSuccess = ! error ; } } else { error = statusText ; if ( status || ! statusText ) { statusText = "error" ; if ( status < 0 ) { status = 0 ; } } } jqXHR . status = status ; jqXHR . statusText = ( nativeStatusText || statusText ) + "" ; if ( isSuccess ) { deferred . resolveWith ( callbackContext , [ success , statusText , jqXHR ] ) ; } else { deferred . rejectWith ( callbackContext , [ jqXHR , statusText , error ] ) ; } jqXHR . statusCode ( statusCode ) ; statusCode = undefined ; if ( fireGlobals ) { globalEventContext . trigger ( isSuccess ? "ajaxSuccess" : "ajaxError" , [ jqXHR , s , isSuccess ? success : error ] ) ; } completeDeferred . fireWith ( callbackContext , [ jqXHR , statusText ] ) ; if ( fireGlobals ) { globalEventContext . trigger ( "ajaxComplete" , [ jqXHR , s ] ) ; if ( ! ( -- jQuery . active ) ) { jQuery . event . trigger ( "ajaxStop" ) ; } } }
Callback for when everything is done
Callback for when everything is done
// Ignore repeat invocations // Clear timeout if it exists // Dereference transport for early garbage collection // (no matter how long the jqXHR object will be used) // Cache response headers // Set readyState // Determine if successful // Get response data // Convert no matter what (that way responseXXX fields are always set) // If successful, handle type chaining // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. // if no content // if not modified // If we have data, let's convert it // Extract error from statusText and normalize for non-aborts // Set data for the fake xhr object // Success/Error // Status-dependent callbacks // Complete // Handle the global AJAX counter