-/**
- * Load HTML from a remote file and inject it into the DOM.
- *
- * @example $("#feeds").load("feeds.html")
- * @before <div id="feeds"></div>
- * @result <div id="feeds"><b>45</b> feeds found.</div>
- *
- * @name load
- * @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
- */
-jQuery.fn.load = function( url, params, callback, ifModified ) {
- if ( url.constructor == Function )
- return this.bind("load", url);
-
- callback = callback || function(){};
-
- // Default to a GET request
- var type = "GET";
-
- // If the second parameter was provided
- if ( params ) {
- // If it's a function
- if ( params.constructor == Function ) {
- // We assume that it's the callback
- callback = params;
- params = null;
-
- // Otherwise, build a param string
- } else {
- params = jQuery.param( params );
- type = "POST";
- }
- }
-
- var self = this;
-
- // Request the remote document
- jQuery.ajax( type, url, params,function(res, status){
-
- if ( status == "success" || !ifModified && status == "notmodified" ) {
- // Inject the HTML into all the matched elements
- self.html(res.responseText).each( callback, [res.responseText, status] );
-
- // Execute all the scripts inside of the newly-injected HTML
- $("script", self).each(function(){
- if ( this.src )
- $.getScript( this.src );
+ /**
+ * Load HTML from a remote file and inject it into the DOM.
+ *
+ * Note: Avoid to use this to load scripts, instead use $.getScript.
+ * IE strips script tags when there aren't any other characters in front of it.
+ *
+ * @example $("#feeds").load("feeds.html");
+ * @before <div id="feeds"></div>
+ * @result <div id="feeds"><b>45</b> feeds found.</div>
+ *
+ * @example $("#feeds").load("feeds.html",
+ * {limit: 25},
+ * function() { alert("The last 25 entries in the feed have been loaded"); }
+ * );
+ * @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 (optional) A set of key/value pairs that will be sent as data to the server.
+ * @param Function callback (optional) A function to be executed whenever the data is loaded (parameters: responseText, status and response itself).
+ * @cat Ajax
+ */
+ load: function( url, params, callback, ifModified ) {
+ if ( jQuery.isFunction( url ) )
+ return this.bind("load", url);
+
+ callback = callback || function(){};
+
+ // Default to a GET request
+ var type = "GET";
+
+ // If the second parameter was provided
+ if ( params )
+ // If it's a function
+ if ( jQuery.isFunction( params.constructor ) ) {
+ // We assume that it's the callback
+ callback = params;
+ params = null;
+
+ // Otherwise, build a param string
+ } else {
+ params = jQuery.param( params );
+ type = "POST";
+ }
+
+ var self = this;
+
+ // Request the remote document
+ jQuery.ajax({
+ 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.attr("innerHTML", res.responseText)
+ // Execute all the scripts inside of the newly-injected HTML
+ .evalScripts()
+ // Execute callback
+ .each( callback, [res.responseText, status, res] );