@@ 6987-7061 (lines=75) @@ | ||
6984 | } |
|
6985 | ||
6986 | jQuery.fn.extend({ |
|
6987 | load: function( url, params, callback ) { |
|
6988 | if ( typeof url !== "string" && _load ) { |
|
6989 | return _load.apply( this, arguments ); |
|
6990 | ||
6991 | // Don't do a request if no elements are being requested |
|
6992 | } else if ( !this.length ) { |
|
6993 | return this; |
|
6994 | } |
|
6995 | ||
6996 | var off = url.indexOf( " " ); |
|
6997 | if ( off >= 0 ) { |
|
6998 | var selector = url.slice( off, url.length ); |
|
6999 | url = url.slice( 0, off ); |
|
7000 | } |
|
7001 | ||
7002 | // Default to a GET request |
|
7003 | var type = "GET"; |
|
7004 | ||
7005 | // If the second parameter was provided |
|
7006 | if ( params ) { |
|
7007 | // If it's a function |
|
7008 | if ( jQuery.isFunction( params ) ) { |
|
7009 | // We assume that it's the callback |
|
7010 | callback = params; |
|
7011 | params = undefined; |
|
7012 | ||
7013 | // Otherwise, build a param string |
|
7014 | } else if ( typeof params === "object" ) { |
|
7015 | params = jQuery.param( params, jQuery.ajaxSettings.traditional ); |
|
7016 | type = "POST"; |
|
7017 | } |
|
7018 | } |
|
7019 | ||
7020 | var self = this; |
|
7021 | ||
7022 | // Request the remote document |
|
7023 | jQuery.ajax({ |
|
7024 | url: url, |
|
7025 | type: type, |
|
7026 | dataType: "html", |
|
7027 | data: params, |
|
7028 | // Complete callback (responseText is used internally) |
|
7029 | complete: function( jqXHR, status, responseText ) { |
|
7030 | // Store the response as specified by the jqXHR object |
|
7031 | responseText = jqXHR.responseText; |
|
7032 | // If successful, inject the HTML into all the matched elements |
|
7033 | if ( jqXHR.isResolved() ) { |
|
7034 | // #4825: Get the actual response in case |
|
7035 | // a dataFilter is present in ajaxSettings |
|
7036 | jqXHR.done(function( r ) { |
|
7037 | responseText = r; |
|
7038 | }); |
|
7039 | // See if a selector was specified |
|
7040 | self.html( selector ? |
|
7041 | // Create a dummy div to hold the results |
|
7042 | jQuery("<div>") |
|
7043 | // inject the contents of the document in, removing the scripts |
|
7044 | // to avoid any 'Permission Denied' errors in IE |
|
7045 | .append(responseText.replace(rscript, "")) |
|
7046 | ||
7047 | // Locate the specified elements |
|
7048 | .find(selector) : |
|
7049 | ||
7050 | // If not, just inject the full result |
|
7051 | responseText ); |
|
7052 | } |
|
7053 | ||
7054 | if ( callback ) { |
|
7055 | self.each( callback, [ responseText, status, jqXHR ] ); |
|
7056 | } |
|
7057 | } |
|
7058 | }); |
|
7059 | ||
7060 | return this; |
|
7061 | }, |
|
7062 | ||
7063 | serialize: function() { |
|
7064 | return jQuery.param( this.serializeArray() ); |
@@ 6100-6174 (lines=75) @@ | ||
6097 | } |
|
6098 | ||
6099 | jQuery.fn.extend({ |
|
6100 | load: function( url, params, callback ) { |
|
6101 | if ( typeof url !== "string" && _load ) { |
|
6102 | return _load.apply( this, arguments ); |
|
6103 | ||
6104 | // Don't do a request if no elements are being requested |
|
6105 | } else if ( !this.length ) { |
|
6106 | return this; |
|
6107 | } |
|
6108 | ||
6109 | var off = url.indexOf( " " ); |
|
6110 | if ( off >= 0 ) { |
|
6111 | var selector = url.slice( off, url.length ); |
|
6112 | url = url.slice( 0, off ); |
|
6113 | } |
|
6114 | ||
6115 | // Default to a GET request |
|
6116 | var type = "GET"; |
|
6117 | ||
6118 | // If the second parameter was provided |
|
6119 | if ( params ) { |
|
6120 | // If it's a function |
|
6121 | if ( jQuery.isFunction( params ) ) { |
|
6122 | // We assume that it's the callback |
|
6123 | callback = params; |
|
6124 | params = null; |
|
6125 | ||
6126 | // Otherwise, build a param string |
|
6127 | } else if ( typeof params === "object" ) { |
|
6128 | params = jQuery.param( params, jQuery.ajaxSettings.traditional ); |
|
6129 | type = "POST"; |
|
6130 | } |
|
6131 | } |
|
6132 | ||
6133 | var self = this; |
|
6134 | ||
6135 | // Request the remote document |
|
6136 | jQuery.ajax({ |
|
6137 | url: url, |
|
6138 | type: type, |
|
6139 | dataType: "html", |
|
6140 | data: params, |
|
6141 | // Complete callback (responseText is used internally) |
|
6142 | complete: function( jXHR, status, responseText ) { |
|
6143 | // Store the response as specified by the jXHR object |
|
6144 | responseText = jXHR.responseText; |
|
6145 | // If successful, inject the HTML into all the matched elements |
|
6146 | if ( jXHR.isResolved() ) { |
|
6147 | // #4825: Get the actual response in case |
|
6148 | // a dataFilter is present in ajaxSettings |
|
6149 | jXHR.done(function( r ) { |
|
6150 | responseText = r; |
|
6151 | }); |
|
6152 | // See if a selector was specified |
|
6153 | self.html( selector ? |
|
6154 | // Create a dummy div to hold the results |
|
6155 | jQuery("<div>") |
|
6156 | // inject the contents of the document in, removing the scripts |
|
6157 | // to avoid any 'Permission Denied' errors in IE |
|
6158 | .append(responseText.replace(rscript, "")) |
|
6159 | ||
6160 | // Locate the specified elements |
|
6161 | .find(selector) : |
|
6162 | ||
6163 | // If not, just inject the full result |
|
6164 | responseText ); |
|
6165 | } |
|
6166 | ||
6167 | if ( callback ) { |
|
6168 | self.each( callback, [ responseText, status, jXHR ] ); |
|
6169 | } |
|
6170 | } |
|
6171 | }); |
|
6172 | ||
6173 | return this; |
|
6174 | }, |
|
6175 | ||
6176 | serialize: function() { |
|
6177 | return jQuery.param( this.serializeArray() ); |