nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / jquery / src / ajax / load.js
1 define( [
2         "../core",
3         "../core/parseHTML",
4         "../ajax",
5         "../traversing",
6         "../manipulation",
7         "../selector",
8
9         // Optional event/alias dependency
10         "../event/alias"
11 ], function( jQuery ) {
12
13 // Keep a copy of the old load method
14 var _load = jQuery.fn.load;
15
16 /**
17  * Load a url into a page
18  */
19 jQuery.fn.load = function( url, params, callback ) {
20         if ( typeof url !== "string" && _load ) {
21                 return _load.apply( this, arguments );
22         }
23
24         var selector, type, response,
25                 self = this,
26                 off = url.indexOf( " " );
27
28         if ( off > -1 ) {
29                 selector = jQuery.trim( url.slice( off ) );
30                 url = url.slice( 0, off );
31         }
32
33         // If it's a function
34         if ( jQuery.isFunction( params ) ) {
35
36                 // We assume that it's the callback
37                 callback = params;
38                 params = undefined;
39
40         // Otherwise, build a param string
41         } else if ( params && typeof params === "object" ) {
42                 type = "POST";
43         }
44
45         // If we have elements to modify, make the request
46         if ( self.length > 0 ) {
47                 jQuery.ajax( {
48                         url: url,
49
50                         // If "type" variable is undefined, then "GET" method will be used.
51                         // Make value of this field explicit since
52                         // user can override it through ajaxSetup method
53                         type: type || "GET",
54                         dataType: "html",
55                         data: params
56                 } ).done( function( responseText ) {
57
58                         // Save response for use in complete callback
59                         response = arguments;
60
61                         self.html( selector ?
62
63                                 // If a selector was specified, locate the right elements in a dummy div
64                                 // Exclude scripts to avoid IE 'Permission Denied' errors
65                                 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
66
67                                 // Otherwise use the full result
68                                 responseText );
69
70                 // If the request succeeds, this function gets "data", "status", "jqXHR"
71                 // but they are ignored because response was set above.
72                 // If it fails, this function gets "jqXHR", "status", "error"
73                 } ).always( callback && function( jqXHR, status ) {
74                         self.each( function() {
75                                 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
76                         } );
77                 } );
78         }
79
80         return this;
81 };
82
83 } );