Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

load() method deprecated?

Tags:

jquery

I was browsing through the jQuery api and noticed that the load method is on the deprecated list.

Categories: Deprecated | Events > Document Loading

I usually use this method to check if images are completly loaded. Why is it deprecated? And what am I supposed to be using instead?

like image 374
Johan Avatar asked Sep 28 '12 15:09

Johan


People also ask

Is jQuery load deprecated?

Note: the jQuery . load() method was deprecated in jQuery 1.8 and removed completely in jQuery 3.0.

Is Window load deprecated?

Note: The load() method deprecated in jQuery version 1.8. It was completely removed in version 3.0.

What is the use of load () function?

The Load function initializes a database and loads it from an input data file. It can be used for initial loading of a database, as part of a database reorganization, or for reloading a database after changing the DBD definition.

What is the 3 parameters of load () method?

This callback function has three different parameters: parameter 1: It contains the result of the content if the method call succeeds. parameter 2: It contains the status of the call function. parameter 3: It contains the XMLHttpRequest object.


1 Answers

See bug #11733, which documents this deprecation:

The .load() method is an ambiguous signature, it can either be an ajax load or attach/fire a "load" event. CCAO cannot tell them apart since it's a dynamic decision based on arguments.

To avoid ambiguities related to the method's signature, it is now recommended to use on() instead. For instance:

$("selector").load(function() {     // ... }); 

Should become:

$("selector").on("load", function() {     // ... }); 
like image 67
Frédéric Hamidi Avatar answered Oct 15 '22 20:10

Frédéric Hamidi