From 03db1ada2cc223edf545c5a452e55062647837fa Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Sun, 2 Dec 2012 00:14:25 -0500 Subject: Fix #12838: hook point for non-jQuery.ajax synchronous script fetch/execute in domManip. Close gh-1051. --- src/ajax.js | 46 +++++++++++++++++++++++----------------------- src/manipulation.js | 20 ++++++++++++-------- 2 files changed, 35 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/ajax.js b/src/ajax.js index 62c3d8ae1..d0a8a4f12 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -194,25 +194,6 @@ jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSucces }; }); -jQuery.each( [ "get", "post" ], function( i, method ) { - jQuery[ method ] = function( url, data, callback, type ) { - // shift arguments if data argument was omitted - if ( jQuery.isFunction( data ) ) { - type = type || callback; - callback = data; - data = undefined; - } - - return jQuery.ajax({ - url: url, - type: method, - dataType: type, - data: data, - success: callback - }); - }; -}); - jQuery.extend({ // Counter for holding the number of active queries @@ -694,15 +675,34 @@ jQuery.extend({ return jqXHR; }, - getScript: function( url, callback ) { - return jQuery.get( url, undefined, callback, "script" ); - }, - getJSON: function( url, data, callback ) { return jQuery.get( url, data, callback, "json" ); + }, + + getScript: function( url, callback ) { + return jQuery.get( url, undefined, callback, "script" ); } }); +jQuery.each( [ "get", "post" ], function( i, method ) { + jQuery[ method ] = function( url, data, callback, type ) { + // shift arguments if data argument was omitted + if ( jQuery.isFunction( data ) ) { + type = type || callback; + callback = data; + data = undefined; + } + + return jQuery.ajax({ + url: url, + type: method, + dataType: type, + data: data, + success: callback + }); + }; +}); + /* Handles responses to an ajax request: * - finds the right dataType (mediates between content-type and expected dataType) * - returns the corresponding response diff --git a/src/manipulation.js b/src/manipulation.js index 640dfcd6f..f37ec421a 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -256,14 +256,7 @@ jQuery.fn.extend({ if ( node.src ) { // Hope ajax is available... - jQuery.ajax({ - url: node.src, - type: "GET", - dataType: "script", - async: false, - global: false, - "throws": true - }); + jQuery._evalUrl( node.src ); } else { jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); } @@ -465,6 +458,17 @@ jQuery.extend({ data_user.discard( elem ); data_priv.discard( elem ); } + }, + + _evalUrl: function( url ) { + return jQuery.ajax({ + url: url, + type: "GET", + dataType: "text", + async: false, + global: false, + success: jQuery.globalEval + }); } }); -- cgit v1.2.3