Blame | Last modification | View Log | RSS feed
define(["../core","../core/parseHTML","../ajax","../traversing","../manipulation","../selector",// Optional event/alias dependency"../event/alias"], function( jQuery ) {// Keep a copy of the old load methodvar _load = jQuery.fn.load;/*** Load a url into a page*/jQuery.fn.load = function( url, params, callback ) {if ( typeof url !== "string" && _load ) {return _load.apply( this, arguments );}var selector, type, response,self = this,off = url.indexOf(" ");if ( off >= 0 ) {selector = jQuery.trim( url.slice( off ) );url = url.slice( 0, off );}// If it's a functionif ( jQuery.isFunction( params ) ) {// We assume that it's the callbackcallback = params;params = undefined;// Otherwise, build a param string} else if ( params && typeof params === "object" ) {type = "POST";}// If we have elements to modify, make the requestif ( self.length > 0 ) {jQuery.ajax({url: url,// if "type" variable is undefined, then "GET" method will be usedtype: type,dataType: "html",data: params}).done(function( responseText ) {// Save response for use in complete callbackresponse = arguments;self.html( selector ?// If a selector was specified, locate the right elements in a dummy div// Exclude scripts to avoid IE 'Permission Denied' errorsjQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :// Otherwise use the full resultresponseText );}).complete( callback && function( jqXHR, status ) {self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );});}return this;};});