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