Cleans up and simplifies code shared by ajaxPrefilter and ajaxTransport. Removes chainability of ajaxSetup, ajaxPrefilter and ajaxTransport. Also makes sure context is handled properly by ajaxSetup (unit test added).

This commit is contained in:
jaubourg
2011-01-20 04:12:15 +01:00
parent 96b00a4935
commit 64e1cdbb95
4 changed files with 139 additions and 114 deletions

View File

@@ -14,9 +14,10 @@ jQuery.ajaxSetup({
converters: {
"text script": jQuery.globalEval
}
});
// Handle cache's special case and global
}).ajaxPrefilter("script", function(s) {
jQuery.ajaxPrefilter("script", function(s) {
if ( s.cache === undefined ) {
s.cache = false;
@@ -26,9 +27,10 @@ jQuery.ajaxSetup({
s.type = "GET";
s.global = false;
}
});
// Bind script tag hack transport
}).ajaxTransport("script", function(s) {
jQuery.ajaxTransport("script", function(s) {
// This transport only deals with cross domain requests
if ( s.crossDomain ) {