Sha256: 6244e36335c7729f8e95818d41a73e1401a605f8452a04ae9b57f05f1736e8ac

Contents?: true

Size: 1.97 KB

Versions: 152

Compression:

Stored size: 1.97 KB

Contents

define( [
	"../core",
	"../core/parseHTML",
	"../ajax",
	"../traversing",
	"../manipulation",
	"../selector",

	// Optional event/alias dependency
	"../event/alias"
], function( jQuery ) {

// Keep a copy of the old load method
var _load = jQuery.fn.load;

/**
 * Load a url into a page
 */
jQuery.fn.load = function( url, params, callback ) {
	if ( typeof url !== "string" && _load ) {
		return _load.apply( this, arguments );
	}

	var selector, type, response,
		self = this,
		off = url.indexOf( " " );

	if ( off > -1 ) {
		selector = jQuery.trim( url.slice( off ) );
		url = url.slice( 0, off );
	}

	// If it's a function
	if ( jQuery.isFunction( params ) ) {

		// We assume that it's the callback
		callback = params;
		params = undefined;

	// Otherwise, build a param string
	} else if ( params && typeof params === "object" ) {
		type = "POST";
	}

	// If we have elements to modify, make the request
	if ( self.length > 0 ) {
		jQuery.ajax( {
			url: url,

			// If "type" variable is undefined, then "GET" method will be used.
			// Make value of this field explicit since
			// user can override it through ajaxSetup method
			type: type || "GET",
			dataType: "html",
			data: params
		} ).done( function( responseText ) {

			// Save response for use in complete callback
			response = arguments;

			self.html( selector ?

				// If a selector was specified, locate the right elements in a dummy div
				// Exclude scripts to avoid IE 'Permission Denied' errors
				jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :

				// Otherwise use the full result
				responseText );

		// If the request succeeds, this function gets "data", "status", "jqXHR"
		// but they are ignored because response was set above.
		// If it fails, this function gets "jqXHR", "status", "error"
		} ).always( callback && function( jqXHR, status ) {
			self.each( function() {
				callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
			} );
		} );
	}

	return this;
};

} );

Version data entries

152 entries across 95 versions & 9 rubygems

Version Path
epuber-0.10.3 lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js
epuber-0.10.2 lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js
epuber-0.10.1 lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js
epuber-0.9.3 lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js
epuber-0.9.2 lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js
epuber-0.9.1 lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js
epuber-0.9.0 lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js
epuber-0.8.0 lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js
epuber-0.7.4 lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js
epuber-0.7.3 lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js
epuber-0.7.2 lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js
epuber-0.7.1 lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js
epuber-0.7.0 lib/epuber/third_party/bower/bower_components/jquery/src/ajax/load.js
jekyll-theme-pirati-7.7.1 _sass/foundation-sites/node_modules/jquery/src/ajax/load.js
jekyll-theme-pirati-7.7.1 _sass/foundation-sites/vendor/jquery/src/ajax/load.js
jekyll-theme-pirati-7.7.0 _sass/foundation-sites/vendor/jquery/src/ajax/load.js
jekyll-theme-pirati-7.7.0 _sass/foundation-sites/node_modules/jquery/src/ajax/load.js
jekyll-theme-pirati-7.6.2 _sass/foundation-sites/vendor/jquery/src/ajax/load.js
jekyll-theme-pirati-7.6.2 _sass/foundation-sites/node_modules/jquery/src/ajax/load.js
jekyll-theme-pirati-7.6.1 _sass/foundation-sites/vendor/jquery/src/ajax/load.js