The JQuery .load() definition follows:
.load( url [, data] [, complete(responseText, textStatus, XMLHttpRequest)] );
The data and complete() arguments are optional. Right? But then, how we can call this:
$('#result').load('ajax/test.html', function(){
alert('Load was performed.');
}
How jquery ignores the 2nd argument and knows that we provided the 1st and the 3d argument? And what if the 3d argument is not a function?
If
loadis called with two arguments or more, jQuery checks to see if the second argument is a function or an object. If it’s a function it’s called when theajaxcall is completed. Otherwise it’s used as the params passed with theajaxcall.Relevant parts from the source:
Where
paramsis the second argument toload.isFunctionis the result of the following functions:where
class2typeis an assosiative array containing, among other things, this element: