X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fajax%2Fajax.js;h=0b965e4a1628bbde8f67f3b18e686d2af359e47e;hb=a5dbcaf67579b2266b64ffbdd2a328d180f7f64b;hp=9042a48d5df88952e50fc81ef3f23d3863cb881c;hpb=e6ffe025033f82d752ec4966c6b12c49d8e1dc29;p=jquery.git diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js index 9042a48..0b965e4 100644 --- a/src/ajax/ajax.js +++ b/src/ajax/ajax.js @@ -15,6 +15,7 @@ jQuery.fn.extend({ * @param Function callback (optional) A function to be executed whenever the data is loaded (parameters: responseText, status and response itself). * @cat Ajax */ + // DEPRECATED loadIfModified: function( url, params, callback ) { this.load( url, params, callback, 1 ); }, @@ -47,6 +48,12 @@ jQuery.fn.extend({ if ( jQuery.isFunction( url ) ) return this.bind("load", url); + var off = url.indexOf(" "); + if ( off >= 0 ) { + var selector = url.slice(off, url.length); + url = url.slice(0, off); + } + callback = callback || function(){}; // Default to a GET request @@ -75,15 +82,26 @@ jQuery.fn.extend({ data: params, ifModified: ifModified, complete: function(res, status){ + // If successful, inject the HTML into all the matched elements if ( status == "success" || !ifModified && status == "notmodified" ) - // Inject the HTML into all the matched elements - self.attr("innerHTML", res.responseText) - // Execute all the scripts inside of the newly-injected HTML - .evalScripts() - // Execute callback - .each( callback, [res.responseText, status, res] ); - else - callback.apply( self, [res.responseText, status, res] ); + // See if a selector was specified + self.html( selector ? + // Create a dummy div to hold the results + jQuery("
") + // inject the contents of the document in, removing the scripts + // to avoid any 'Permission Denied' errors in IE + .append(res.responseText.replace(/