1 import { jQuery } from "../core.js";
2 import { stripAndCollapse } from "../core/stripAndCollapse.js";
4 import "../core/parseHTML.js";
6 import "../traversing.js";
7 import "../manipulation.js";
8 import "../selector.js";
11 * Load a url into a page
13 jQuery.fn.load = function( url, params, callback ) {
14 var selector, type, response,
16 off = url.indexOf( " " );
19 selector = stripAndCollapse( url.slice( off ) );
20 url = url.slice( 0, off );
24 if ( typeof params === "function" ) {
26 // We assume that it's the callback
30 // Otherwise, build a param string
31 } else if ( params && typeof params === "object" ) {
35 // If we have elements to modify, make the request
36 if ( self.length > 0 ) {
40 // If "type" variable is undefined, then "GET" method will be used.
41 // Make value of this field explicit since
42 // user can override it through ajaxSetup method
46 } ).done( function( responseText ) {
48 // Save response for use in complete callback
53 // If a selector was specified, locate the right elements in a dummy div
54 // Exclude scripts to avoid IE 'Permission Denied' errors
55 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
57 // Otherwise use the full result
60 // If the request succeeds, this function gets "data", "status", "jqXHR"
61 // but they are ignored because response was set above.
62 // If it fails, this function gets "jqXHR", "status", "error"
63 } ).always( callback && function( jqXHR, status ) {
64 self.each( function() {
65 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );