diff options
| author | Jonathan Barronville | 2014-06-07 19:13:28 -0400 | 
|---|---|---|
| committer | Jonathan Barronville | 2014-06-07 19:13:28 -0400 | 
| commit | b56e5c671ce89f1c8ddc67a4ac8d2f59de04ea85 (patch) | |
| tree | 80ce4d67ff46505dc1ec77b72daf7bed59abf8b4 /bower_components/jquery/src/ajax/load.js | |
| parent | 67ad58c27c4a2704532246d044e1ecbae2a11022 (diff) | |
| download | sellevate-b56e5c671ce89f1c8ddc67a4ac8d2f59de04ea85.tar.bz2 | |
Yo.
Diffstat (limited to 'bower_components/jquery/src/ajax/load.js')
| -rw-r--r-- | bower_components/jquery/src/ajax/load.js | 75 | 
1 files changed, 75 insertions, 0 deletions
| diff --git a/bower_components/jquery/src/ajax/load.js b/bower_components/jquery/src/ajax/load.js new file mode 100644 index 0000000..bff25b1 --- /dev/null +++ b/bower_components/jquery/src/ajax/load.js @@ -0,0 +1,75 @@ +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 >= 0 ) { +		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 +			type: type, +			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 ); + +		}).complete( callback && function( jqXHR, status ) { +			self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); +		}); +	} + +	return this; +}; + +}); | 
