Sha256: 2e1e9cd9dd18d1454771fe627b66cd0cac0436b646afa277e69e37d398394317

Contents?: true

Size: 1.83 KB

Versions: 75

Compression:

Stored size: 1.83 KB

Contents

define( [
	"../core",
	"../core/stripAndCollapse",
	"../core/parseHTML",
	"../ajax",
	"../traversing",
	"../manipulation",
	"../selector"
], function( jQuery, stripAndCollapse ) {

"use strict";

/**
 * Load a url into a page
 */
jQuery.fn.load = function( url, params, callback ) {
	var selector, type, response,
		self = this,
		off = url.indexOf( " " );

	if ( off > -1 ) {
		selector = stripAndCollapse( 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

75 entries across 65 versions & 13 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/jquery/src/ajax/load.js
columbus3-0.5.1 bower_components/jquery/src/ajax/load.js
trusty-cms-3.6.0 spec/dummy/node_modules/jquery/src/ajax/load.js
trusty-cms-3.6.0 node_modules/jquery/src/ajax/load.js
trusty-cms-3.5.5 spec/dummy/node_modules/jquery/src/ajax/load.js
trusty-cms-3.5.5 node_modules/jquery/src/ajax/load.js
trusty-cms-3.5.4 spec/dummy/node_modules/jquery/src/ajax/load.js
trusty-cms-3.5.4 node_modules/jquery/src/ajax/load.js
trusty-cms-3.5.3 node_modules/jquery/src/ajax/load.js
trusty-cms-3.5.3 spec/dummy/node_modules/jquery/src/ajax/load.js
trusty-cms-3.5.2 spec/dummy/node_modules/jquery/src/ajax/load.js
trusty-cms-3.5.2 node_modules/jquery/src/ajax/load.js
trusty-cms-3.5.1 spec/dummy/node_modules/jquery/src/ajax/load.js
trusty-cms-3.5.1 node_modules/jquery/src/ajax/load.js
optimacms-0.4.3 spec/dummy/node_modules/jquery/src/ajax/load.js
optimacms-0.4.2 spec/dummy/node_modules/jquery/src/ajax/load.js
trusty-cms-3.5.0 node_modules/jquery/src/ajax/load.js
trusty-cms-3.5.0 spec/dummy/node_modules/jquery/src/ajax/load.js
trusty-cms-3.4.0 spec/dummy/node_modules/jquery/src/ajax/load.js
trusty-cms-3.4.0 node_modules/jquery/src/ajax/load.js