.on load - does not work JQUERY

Asked

Viewed 222 times

0

Really, I couldn’t understand.

In the past I always used jquery’s load function like this:

$('#db0077').load('/inc/aula.php', function(){
        alert('dentro do load');
    });

Now this function is obsolete. So I saw that I have to use . on() for this. Use . on() it’s very simple, with you in all functions except this!!! I tried so:

$('#db0077').on('load', '/inc/aula.php', function(){
        alert('dentro do load');
    });

It doesn’t work at all, someone gives me a light?

  • Ann... who told you the method load is obsolete??

1 answer

1

The method .load() always worked as an Ajax shorthand. Before jQuery 1.8 the method also functioned as event load of Javascript, that is, $(window).load() was the same as window.onload. As of version 1.8 the method became obsolete for this event and was removed from version 3.0, leaving only the Ajax function.

The method .on() is used to trigger events (click, change, load etc.), only in the case of load is used with asynchronous elements: $(window).on("load"..., $("img").on("load"..., $("iframe").on("load"... etc. Does not work with div because div is not asynchronous.

In short, keep using .load() to load content in div that is not obsolete no. What has become obsolete since version 1.8 was the use of .load() as an event.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.