scratch – Blame information for rev 125
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
125 | office | 1 | define([ |
58 | office | 2 | "../core", |
3 | "../core/parseHTML", |
||
4 | "../ajax", |
||
5 | "../traversing", |
||
6 | "../manipulation", |
||
125 | office | 7 | "../selector", |
8 | // Optional event/alias dependency |
||
9 | "../event/alias" |
||
10 | ], function( jQuery ) { |
||
58 | office | 11 | |
125 | office | 12 | // Keep a copy of the old load method |
13 | var _load = jQuery.fn.load; |
||
58 | office | 14 | |
15 | /** |
||
16 | * Load a url into a page |
||
17 | */ |
||
18 | jQuery.fn.load = function( url, params, callback ) { |
||
125 | office | 19 | if ( typeof url !== "string" && _load ) { |
20 | return _load.apply( this, arguments ); |
||
21 | } |
||
22 | |||
58 | office | 23 | var selector, type, response, |
24 | self = this, |
||
125 | office | 25 | off = url.indexOf(" "); |
58 | office | 26 | |
125 | office | 27 | if ( off >= 0 ) { |
28 | selector = jQuery.trim( url.slice( off ) ); |
||
58 | office | 29 | url = url.slice( 0, off ); |
30 | } |
||
31 | |||
32 | // If it's a function |
||
33 | if ( jQuery.isFunction( params ) ) { |
||
34 | |||
35 | // We assume that it's the callback |
||
36 | callback = params; |
||
37 | params = undefined; |
||
38 | |||
39 | // Otherwise, build a param string |
||
40 | } else if ( params && typeof params === "object" ) { |
||
41 | type = "POST"; |
||
42 | } |
||
43 | |||
44 | // If we have elements to modify, make the request |
||
45 | if ( self.length > 0 ) { |
||
125 | office | 46 | jQuery.ajax({ |
58 | office | 47 | url: url, |
48 | |||
125 | office | 49 | // if "type" variable is undefined, then "GET" method will be used |
50 | type: type, |
||
58 | office | 51 | dataType: "html", |
52 | data: params |
||
125 | office | 53 | }).done(function( responseText ) { |
58 | office | 54 | |
55 | // Save response for use in complete callback |
||
56 | response = arguments; |
||
57 | |||
58 | self.html( selector ? |
||
59 | |||
60 | // If a selector was specified, locate the right elements in a dummy div |
||
61 | // Exclude scripts to avoid IE 'Permission Denied' errors |
||
125 | office | 62 | jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) : |
58 | office | 63 | |
64 | // Otherwise use the full result |
||
65 | responseText ); |
||
66 | |||
125 | office | 67 | }).complete( callback && function( jqXHR, status ) { |
68 | self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); |
||
69 | }); |
||
58 | office | 70 | } |
71 | |||
72 | return this; |
||
73 | }; |
||
74 | |||
125 | office | 75 | }); |