3 "../core/stripAndCollapse",
9 ], function( jQuery, stripAndCollapse ) {
14 * Load a url into a page
16 jQuery.fn.load = function( url, params, callback ) {
17 var selector, type, response,
19 off = url.indexOf( " " );
22 selector = stripAndCollapse( url.slice( off ) );
23 url = url.slice( 0, off );
27 if ( jQuery.isFunction( params ) ) {
29 // We assume that it's the callback
33 // Otherwise, build a param string
34 } else if ( params && typeof params === "object" ) {
38 // If we have elements to modify, make the request
39 if ( self.length > 0 ) {
43 // If "type" variable is undefined, then "GET" method will be used.
44 // Make value of this field explicit since
45 // user can override it through ajaxSetup method
49 } ).done( function( responseText ) {
51 // Save response for use in complete callback
56 // If a selector was specified, locate the right elements in a dummy div
57 // Exclude scripts to avoid IE 'Permission Denied' errors
58 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
60 // Otherwise use the full result
63 // If the request succeeds, this function gets "data", "status", "jqXHR"
64 // but they are ignored because response was set above.
65 // If it fails, this function gets "jqXHR", "status", "error"
66 } ).always( callback && function( jqXHR, status ) {
67 self.each( function() {
68 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );