+
+ 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.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] );
+ }
+ });
+ return this;
+ },
+
+ /**
+ * Serializes a set of input elements into a string of data.
+ * This will serialize all given elements.
+ *
+ * A serialization similar to the form submit of a browser is
+ * provided by the form plugin. It also takes multiple-selects
+ * into account, while this method recognizes only a single option.
+ *
+ * @example $("input[@type=text]").serialize();
+ * @before <input type='text' name='name' value='John'/>
+ * <input type='text' name='location' value='Boston'/>
+ * @after name=John&location=Boston
+ * @desc Serialize a selection of input elements to a string
+ *
+ * @name serialize
+ * @type String
+ * @cat AJAX
+ */
+ serialize: function() {
+ return jQuery.param( this );
+ },
+
+ /**
+ * Evaluate all script tags inside this jQuery. If they have a src attribute,
+ * the script is loaded, otherwise it's content is evaluated.
+ *
+ * @name evalScripts
+ * @type jQuery
+ * @private
+ * @cat AJAX
+ */
+ evalScripts: function() {
+ return this.find('script').each(function(){
+ if ( this.src )
+ jQuery.getScript( this.src );
+ else {
+ jQuery.globalEval( this.text || this.textContent || this.innerHTML || "" );
+ }
+ }).end();