Code has been added to clipboard!

jQuery .load(): Get to Know This Deprecated Method

Reading time 2 min
Published Jan 8, 2018
Updated Oct 10, 2019

jQuery load: Main Tips

  • The now removed jQuery .load() method attached an event handler to the load event.
  • The load event triggers when an element and all the sub-elements related to it finish loading.
  • You can still use the AJAX .load() method in jQuery. However, despite the same name, it has a different purpose, so don't confuse the two!
Udacity
Pros
  • Simplistic design (no unnecessary information)
  • High-quality courses (even the free ones)
  • Variety of features
Main Features
  • Nanodegree programs
  • Suitable for enterprises
  • Paid certificates of completion
Coursera
Pros
  • Professional service
  • Flexible timetables
  • A variety of features to choose from
Main Features
  • Professional certificates of completion
  • University-level courses
  • Multiple Online degree programs
Datacamp
Pros
  • Great user experience
  • Offers quality content
  • Very transparent with their pricing
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable

Usage and Syntax of .load()

The .load() jQuery method attached an event handler that executed a function when the specified element was fully loaded. Using the example below, an alert would have popped up when the page finished loading:

Example
$("window").load(function(
{
	alert("The window has loaded!");
});

As you can see, the jQuery .load() function followed rather simple syntax:

$("selector").load(function);

Basically, jQuery .load() was a shortcut for using the .on() method with its parameters defined as "load", handler. You can still use this syntax to achieve the same result.

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

Don't Get Mixed Up: .load() by AJAX

You cannot use the jQuery .load() method for event handlers now. However, you can use a method with the same name to get data from a server. While the name might add to confusion, this .load() is actually an AJAX method.

Before the event handling .load() method was removed, jQuery chose which of the two to execute based on the defined arguments. The currently unsupported method took just one (function), and the AJAX method takes three (a required URL, plus the optional data and callback).

Latest Udacity Coupon Found:

Verified STAFF PICK

75% OFF COURSES

Udacity Black Friday Offer

The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!

Expiration date: 22/01/2021
3176 People Used
Only 97 Left
Rating
5.0