Moved jQuery.ajax.prefilter and jQuery.ajax.transport to jQuery.ajaxPrefilter and jQuery.ajaxTransport so that proxying the ajax method doesn't turn into a nightmare. Thanks go to scott_gonzalez and DaveMethvin for pointing out the issue. Also made ajaxSetup return "this" to enable chainable definitions -- jQuery.ajaxSetup(...).ajaxPrefilter(...).ajaxTransport(...).
This commit is contained in:
parent
44fc87f66c
commit
a8fa5f2ec1
4 changed files with 11 additions and 12 deletions
13
src/ajax.js
13
src/ajax.js
|
@ -161,6 +161,7 @@ jQuery.extend({
|
||||||
|
|
||||||
ajaxSetup: function( settings ) {
|
ajaxSetup: function( settings ) {
|
||||||
jQuery.extend( true, jQuery.ajaxSettings, settings );
|
jQuery.extend( true, jQuery.ajaxSettings, settings );
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
ajaxSettings: {
|
ajaxSettings: {
|
||||||
|
@ -599,7 +600,7 @@ jQuery.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get transport
|
// Get transport
|
||||||
transport = jQuery.ajax.prefilter( s , options ).transport( s );
|
transport = jQuery.ajaxPrefilter( s , options ).ajaxTransport( s );
|
||||||
|
|
||||||
// Watch for a new set of requests
|
// Watch for a new set of requests
|
||||||
if ( s.global && jQuery.active++ === 0 ) {
|
if ( s.global && jQuery.active++ === 0 ) {
|
||||||
|
@ -849,7 +850,7 @@ function ajax_selectOrExecute( structure , s ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return noSelect ? jQuery.ajax : selected;
|
return noSelect ? jQuery : selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add an element to one of the structures in ajaxSettings
|
// Add an element to one of the structures in ajaxSettings
|
||||||
|
@ -908,13 +909,13 @@ function ajax_addElement( structure , args ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return jQuery.ajax;
|
return jQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Install prefilter & transport methods
|
// Install prefilter & transport methods
|
||||||
jQuery.each( [ "prefilter" , "transport" ] , function( _ , name ) {
|
jQuery.each( [ "Prefilter" , "Transport" ] , function( _ , name ) {
|
||||||
_ = name + "s";
|
_ = name.toLowerCase() + "s";
|
||||||
jQuery.ajax[ name ] = function() {
|
jQuery[ "ajax" + name ] = function() {
|
||||||
return ajax_addElement( _ , arguments );
|
return ajax_addElement( _ , arguments );
|
||||||
};
|
};
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -10,12 +10,11 @@ jQuery.ajaxSetup({
|
||||||
jsonpCallback: function() {
|
jsonpCallback: function() {
|
||||||
return "jsonp" + jsc++;
|
return "jsonp" + jsc++;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
// Normalize jsonp queries
|
// Normalize jsonp queries
|
||||||
// 1) put callback parameter in url or data
|
// 1) put callback parameter in url or data
|
||||||
// 2) sneakily ensure transportDataType is always jsonp for jsonp requests
|
// 2) sneakily ensure transportDataType is always jsonp for jsonp requests
|
||||||
jQuery.ajax.prefilter("json jsonp", function(s, originalSettings) {
|
}).ajaxPrefilter("json jsonp", function(s, originalSettings) {
|
||||||
|
|
||||||
if ( s.dataTypes[ 0 ] === "jsonp" ||
|
if ( s.dataTypes[ 0 ] === "jsonp" ||
|
||||||
originalSettings.jsonp ||
|
originalSettings.jsonp ||
|
||||||
|
@ -38,7 +37,7 @@ jQuery.ajax.prefilter("json jsonp", function(s, originalSettings) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind transport to jsonp dataType
|
// Bind transport to jsonp dataType
|
||||||
}).transport("jsonp", function(s) {
|
}).ajaxTransport("jsonp", function(s) {
|
||||||
|
|
||||||
// Put callback in place
|
// Put callback in place
|
||||||
var responseContainer,
|
var responseContainer,
|
||||||
|
|
|
@ -14,10 +14,9 @@ jQuery.ajaxSetup({
|
||||||
converters: {
|
converters: {
|
||||||
"text script": jQuery.globalEval
|
"text script": jQuery.globalEval
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
// Bind script tag hack transport
|
// Bind script tag hack transport
|
||||||
jQuery.ajax.transport("script", function(s) {
|
}).ajaxTransport("script", function(s) {
|
||||||
|
|
||||||
// Handle cache special case
|
// Handle cache special case
|
||||||
if ( s.cache === undefined ) {
|
if ( s.cache === undefined ) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ var // Next active xhr id
|
||||||
xhrUnloadAbortInstalled;
|
xhrUnloadAbortInstalled;
|
||||||
|
|
||||||
|
|
||||||
jQuery.ajax.transport( function( s , determineDataType ) {
|
jQuery.ajaxTransport( function( s , determineDataType ) {
|
||||||
|
|
||||||
// Cross domain only allowed if supported through XMLHttpRequest
|
// Cross domain only allowed if supported through XMLHttpRequest
|
||||||
if ( ! s.crossDomain || jQuery.support.cors ) {
|
if ( ! s.crossDomain || jQuery.support.cors ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue