rantiCache = /([?&])_=[^&]*/,
rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
// #7653, #8125, #8152: local protocol detection
rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
rnoContent = /^(?:GET|HEAD)$/,
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
* - BEFORE asking for a transport
* - AFTER param serialization (s.data is a string if s.processData is true)
* 4) the catchall symbol "*" can be used
* 5) execution will start with transport dataType and THEN continue down to "*" if needed
* 2) the catchall symbol "*" can be used
* 3) selection will start with transport dataType and THEN go to "*" if needed
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
allTypes = "*/".concat( "*" ),
// Anchor tag for parsing the document origin
originAnchor = document.createElement( "a" );
originAnchor.href = location.href;
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
function addToPrefiltersOrTransports( structure ) {
// dataTypeExpression is optional and defaults to "*"
return function( dataTypeExpression, func ) {
if ( typeof dataTypeExpression !== "string" ) {
func = dataTypeExpression;
dataTypeExpression = "*";
dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
if ( isFunction( func ) ) {
// For each dataType in the dataTypeExpression
while ( ( dataType = dataTypes[ i++ ] ) ) {
if ( dataType[ 0 ] === "+" ) {
dataType = dataType.slice( 1 ) || "*";
( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
// Base inspection function for prefilters and transports
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
seekingTransport = ( structure === transports );
function inspect( dataType ) {
inspected[ dataType ] = true;
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
if ( typeof dataTypeOrTransport === "string" &&
!seekingTransport && !inspected[ dataTypeOrTransport ] ) {
options.dataTypes.unshift( dataTypeOrTransport );
inspect( dataTypeOrTransport );
} else if ( seekingTransport ) {
return !( selected = dataTypeOrTransport );
return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
// A special extend for ajax options
// that takes "flat" options (not to be deep extended)
function ajaxExtend( target, src ) {
flatOptions = jQuery.ajaxSettings.flatOptions || {};
if ( src[ key ] !== undefined ) {
( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
jQuery.extend( true, target, deep );
/* Handles responses to an ajax request:
* - finds the right dataType (mediates between content-type and expected dataType)
* - returns the corresponding response
function ajaxHandleResponses( s, jqXHR, responses ) {
var ct, type, finalDataType, firstDataType,
// Remove auto dataType and get content-type in the process
while ( dataTypes[ 0 ] === "*" ) {
if ( ct === undefined ) {
ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
// Check if we're dealing with a known content-type
for ( type in contents ) {
if ( contents[ type ] && contents[ type ].test( ct ) ) {
dataTypes.unshift( type );
// Check to see if we have a response for the expected dataType
if ( dataTypes[ 0 ] in responses ) {
finalDataType = dataTypes[ 0 ];
// Try convertible dataTypes
for ( type in responses ) {
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
finalDataType = finalDataType || firstDataType;
// If we found a dataType
// We add the dataType to the list if needed
// and return the corresponding response
if ( finalDataType !== dataTypes[ 0 ] ) {
dataTypes.unshift( finalDataType );
return responses[ finalDataType ];
/* Chain conversions given the request and the original response
* Also sets the responseXXX fields on the jqXHR instance
function ajaxConvert( s, response, jqXHR, isSuccess ) {
var conv2, current, conv, tmp, prev,
// Work with a copy of dataTypes in case we need to modify it for conversion
dataTypes = s.dataTypes.slice();
// Create converters map with lowercased keys
for ( conv in s.converters ) {
converters[ conv.toLowerCase() ] = s.converters[ conv ];
current = dataTypes.shift();
// Convert to each sequential dataType
if ( s.responseFields[ current ] ) {
jqXHR[ s.responseFields[ current ] ] = response;
// Apply the dataFilter if provided
if ( !prev && isSuccess && s.dataFilter ) {
response = s.dataFilter( response, s.dataType );
current = dataTypes.shift();
// There's only work to do if current dataType is non-auto
// Convert response if prev dataType is non-auto and differs from current
} else if ( prev !== "*" && prev !== current ) {
// Seek a direct converter
conv = converters[ prev + " " + current ] || converters[ "* " + current ];
// If none found, seek a pair
for ( conv2 in converters ) {
// If conv2 outputs current
tmp = conv2.split( " " );
if ( tmp[ 1 ] === current ) {
// If prev can be converted to accepted input
conv = converters[ prev + " " + tmp[ 0 ] ] ||
converters[ "* " + tmp[ 0 ] ];
// Condense equivalence converters
conv = converters[ conv2 ];
// Otherwise, insert the intermediate dataType
} else if ( converters[ conv2 ] !== true ) {
dataTypes.unshift( tmp[ 1 ] );
// Apply converter (if not an equivalence)
// Unless errors are allowed to bubble, catch and return them
if ( conv && s.throws ) {
response = conv( response );
response = conv( response );
error: conv ? e : "No conversion from " + prev + " to " + current
return { state: "success", data: response };
// Counter for holding the number of active queries
// Last-Modified header cache for next request
isLocal: rlocalProtocol.test( location.protocol ),
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
xml: "application/xml, text/xml",
json: "application/json, text/javascript"
// Keys separate source (or catchall "*") and destination types with a single space
// Convert anything to text
// Text to html (true = no transformation)
// Evaluate text as a json expression
"text xml": jQuery.parseXML
// For options that shouldn't be deep extended:
// you can add your own custom options here if
// and when you create one that shouldn't be
// deep extended (see ajaxExtend)
// Creates a full fledged settings object into target
// with both ajaxSettings and settings fields.
// If target is omitted, writes into ajaxSettings.
ajaxSetup: function( target, settings ) {
// Building a settings object
ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
// Extending ajaxSettings
ajaxExtend( jQuery.ajaxSettings, target );
ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
ajaxTransport: addToPrefiltersOrTransports( transports ),
ajax: function( url, options ) {
// If url is an object, simulate pre-1.5 signature
if ( typeof url === "object" ) {
// Force options to be an object
// URL without anti-cache param
// Request state (becomes false upon send and true upon completion)
// To know if global events are to be dispatched
// uncached part of the url
// Create the final options object
s = jQuery.ajaxSetup( {}, options ),
callbackContext = s.context || s,
// Context for global events is callbackContext if it is a DOM node or jQuery collection
globalEventContext = s.context &&
( callbackContext.nodeType || callbackContext.jquery ) ?
jQuery( callbackContext ) :
deferred = jQuery.Deferred(),
completeDeferred = jQuery.Callbacks( "once memory" ),
// Status-dependent callbacks
statusCode = s.statusCode || {},
// Headers (they are sent all at once)
requestHeadersNames = {},
// Builds headers hashtable if needed
getResponseHeader: function( key ) {
if ( !responseHeaders ) {
while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
match = responseHeaders[ key.toLowerCase() + " " ];
return match == null ? null : match.join( ", " );
getAllResponseHeaders: function() {
return completed ? responseHeadersString : null;
setRequestHeader: function( name, value ) {
if ( completed == null ) {
name = requestHeadersNames[ name.toLowerCase() ] =
requestHeadersNames[ name.toLowerCase() ] || name;
requestHeaders[ name ] = value;
// Overrides response content-type header
overrideMimeType: function( type ) {
if ( completed == null ) {
// Status-dependent callbacks
statusCode: function( map ) {
// Execute the appropriate callbacks
jqXHR.always( map[ jqXHR.status ] );
// Lazy-add the new callbacks in a way that preserves old ones
statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
abort: function( statusText ) {
var finalText = statusText || strAbort;