1 | define([
|
2 | "../core",
|
3 | "../core/parseHTML",
|
4 | "../ajax",
|
5 | "../traversing",
|
6 | "../manipulation",
|
7 | "../selector",
|
8 |
|
9 | "../event/alias"
|
10 | ], function( jQuery ) {
|
11 |
|
12 |
|
13 | var _load = jQuery.fn.load;
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | jQuery.fn.load = function( url, params, callback ) {
|
19 | if ( typeof url !== "string" && _load ) {
|
20 | return _load.apply( this, arguments );
|
21 | }
|
22 |
|
23 | var selector, type, response,
|
24 | self = this,
|
25 | off = url.indexOf(" ");
|
26 |
|
27 | if ( off >= 0 ) {
|
28 | selector = jQuery.trim( url.slice( off ) );
|
29 | url = url.slice( 0, off );
|
30 | }
|
31 |
|
32 |
|
33 | if ( jQuery.isFunction( params ) ) {
|
34 |
|
35 |
|
36 | callback = params;
|
37 | params = undefined;
|
38 |
|
39 |
|
40 | } else if ( params && typeof params === "object" ) {
|
41 | type = "POST";
|
42 | }
|
43 |
|
44 |
|
45 | if ( self.length > 0 ) {
|
46 | jQuery.ajax({
|
47 | url: url,
|
48 |
|
49 |
|
50 | type: type,
|
51 | dataType: "html",
|
52 | data: params
|
53 | }).done(function( responseText ) {
|
54 |
|
55 |
|
56 | response = arguments;
|
57 |
|
58 | self.html( selector ?
|
59 |
|
60 |
|
61 |
|
62 | jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
|
63 |
|
64 |
|
65 | responseText );
|
66 |
|
67 | }).complete( callback && function( jqXHR, status ) {
|
68 | self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
|
69 | });
|
70 | }
|
71 |
|
72 | return this;
|
73 | };
|
74 |
|
75 | });
|