scratch – Diff between revs 58 and 125

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 58 Rev 125
Line 1... Line 1...
1 define( [ 1 define([
2 "../core", 2 "../core",
3 "../core/stripAndCollapse", -  
4 "../core/parseHTML", 3 "../core/parseHTML",
5 "../ajax", 4 "../ajax",
6 "../traversing", 5 "../traversing",
7 "../manipulation", 6 "../manipulation",
8 "../selector" 7 "../selector",
-   8 // Optional event/alias dependency
-   9 "../event/alias"
9 ], function( jQuery, stripAndCollapse ) { 10 ], function( jQuery ) {
Line -... Line 11...
-   11  
10   12 // Keep a copy of the old load method
Line 11... Line 13...
11 "use strict"; 13 var _load = jQuery.fn.load;
12   14  
13 /** 15 /**
14 * Load a url into a page 16 * Load a url into a page
-   17 */
-   18 jQuery.fn.load = function( url, params, callback ) {
-   19 if ( typeof url !== "string" && _load ) {
-   20 return _load.apply( this, arguments );
15 */ 21 }
16 jQuery.fn.load = function( url, params, callback ) { 22  
17 var selector, type, response, 23 var selector, type, response,
Line 18... Line 24...
18 self = this, 24 self = this,
19 off = url.indexOf( " " ); 25 off = url.indexOf(" ");
20   26  
21 if ( off > -1 ) { 27 if ( off >= 0 ) {
Line 22... Line 28...
22 selector = stripAndCollapse( url.slice( off ) ); 28 selector = jQuery.trim( url.slice( off ) );
23 url = url.slice( 0, off ); 29 url = url.slice( 0, off );
Line 35... Line 41...
35 type = "POST"; 41 type = "POST";
36 } 42 }
Line 37... Line 43...
37   43  
38 // If we have elements to modify, make the request 44 // If we have elements to modify, make the request
39 if ( self.length > 0 ) { 45 if ( self.length > 0 ) {
40 jQuery.ajax( { 46 jQuery.ajax({
Line 41... Line 47...
41 url: url, 47 url: url,
42   -  
43 // If "type" variable is undefined, then "GET" method will be used. -  
44 // Make value of this field explicit since 48  
45 // user can override it through ajaxSetup method 49 // if "type" variable is undefined, then "GET" method will be used
46 type: type || "GET", 50 type: type,
47 dataType: "html", 51 dataType: "html",
Line 48... Line 52...
48 data: params 52 data: params
49 } ).done( function( responseText ) { 53 }).done(function( responseText ) {
Line 50... Line 54...
50   54  
Line 51... Line 55...
51 // Save response for use in complete callback 55 // Save response for use in complete callback
52 response = arguments; 56 response = arguments;
53   57  
Line 54... Line 58...
54 self.html( selector ? 58 self.html( selector ?
55   59  
Line 56... Line -...
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 ) : -  
59   60 // If a selector was specified, locate the right elements in a dummy div
60 // Otherwise use the full result -  
61 responseText ); 61 // Exclude scripts to avoid IE 'Permission Denied' errors
62   -  
63 // If the request succeeds, this function gets "data", "status", "jqXHR" 62 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
64 // but they are ignored because response was set above. 63  
Line 65... Line 64...
65 // If it fails, this function gets "jqXHR", "status", "error" 64 // Otherwise use the full result
66 } ).always( callback && function( jqXHR, status ) { 65 responseText );
Line 67... Line 66...
67 self.each( function() { 66