X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fajax%2Fajax.js;h=ffe30481d37e956024115124454c52801b82f9eb;hb=f96bf1041553775a94c1034c97e253e350217173;hp=b8ccdd65220e210a0cfb3d5fa9d30156c15f1a11;hpb=46faa03820f82e5b03e6b3d73bd9d5b194b2b310;p=jquery.git
diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js
index b8ccdd6..ffe3048 100644
--- a/src/ajax/ajax.js
+++ b/src/ajax/ajax.js
@@ -1,58 +1,23 @@
jQuery.fn.extend({
-
- /**
- * Load HTML from a remote file and inject it into the DOM, only if it's
- * been modified by the server.
- *
- * @example $("#feeds").loadIfModified("feeds.html")
- * @before
- * @result 45 feeds found.
- *
- * @name loadIfModified
- * @type jQuery
- * @param String url The URL of the HTML file to load.
- * @param Hash params A set of key/value pairs that will be sent to the server.
- * @param Function callback A function to be executed whenever the data is loaded.
- * @cat AJAX
- */
- loadIfModified: function( url, params, callback ) {
- this.load( url, params, callback, 1 );
- },
-
- /**
- * Load HTML from a remote file and inject it into the DOM.
- *
- * @example $("#feeds").load("feeds.html")
- * @before
- * @result 45 feeds found.
- *
- * @example $("#feeds").load("feeds.html",
- * {test: true},
- * function() { alert("load is done"); }
- * );
- * @desc Same as above, but with an additional parameter
- * and a callback that is executed when the data was loaded.
- *
- * @name load
- * @type jQuery
- * @param String url The URL of the HTML file to load.
- * @param Object params A set of key/value pairs that will be sent as data to the server.
- * @param Function callback A function to be executed whenever the data is loaded (parameters: responseText, status and reponse itself).
- * @cat AJAX
- */
- load: function( url, params, callback, ifModified ) {
- if ( url.constructor == Function )
+ load: function( url, params, callback ) {
+ 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
var type = "GET";
// If the second parameter was provided
- if ( params ) {
+ if ( params )
// If it's a function
- if ( params.constructor == Function ) {
+ if ( jQuery.isFunction( params ) ) {
// We assume that it's the callback
callback = params;
params = null;
@@ -62,7 +27,6 @@ jQuery.fn.extend({
params = jQuery.param( params );
type = "POST";
}
- }
var self = this;
@@ -71,313 +35,95 @@ jQuery.fn.extend({
url: url,
type: type,
data: params,
- ifModified: ifModified,
complete: function(res, status){
- if ( status == "success" || !ifModified && status == "notmodified" ) {
- // Inject the HTML into all the matched elements
- self.html(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] );
+ // If successful, inject the HTML into all the matched elements
+ if ( status == "success" || status == "notmodified" )
+ // 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(/