6

jQuery.fn.load() is deprecated in jquery 3.X.X? I'm making a mess with documentation.

mycode is: $("#myDiv").load('mypage.html');

How I can load mypage.html into #myDiv?

2 Answers2

15

Your code is correct. This load method you use isn't deprecated, but the load event is.

Philip Bijker
  • 4,955
  • 2
  • 36
  • 44
1

From Beamtic's website

You can try replacing the load() method with on('load', ...)

Given deprecated code:

tjq(this).load(function() {
  tjq(this).closest(".middle-block").middleblock();
});

Try changing it to:

tjq(this).on('load', function() {
  tjq(this).closest(".middle-block").middleblock();
});

Jacob's webpage linked to at the top of this post also gives solutions to other similar deprecated jQuery code.

That said, since you are passing in a URL, not a function, I am not sure how that would translate to your case. I mean I guess $("#myDiv") is a function?).

To be sure, many people (including myself before now) are looking for the solution shown above. I am just not sure exactly how to translate your code to work for you.

SherylHohman
  • 16,580
  • 17
  • 88
  • 94