.on load - does not work JQUERY

0

Seriously, I could not understand.

I used to always use the jquery load function like this:

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

Now this function is deprecated. So I saw that I have to use .on () for this. Using .on () is very simple, I get it in all functions, except that !!! I tried it like this:

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

It does not work at all, does anyone give me a light?

    
asked by anonymous 01.12.2018 / 19:38

1 answer

1

The .load() method always worked as an Ajax shorthand. Before jQuery 1.8 the method also worked as a% of JavaScript event, that is, load was the same as $(window).load() . As of version 1.8 the method has become obsolete for this event and has been removed from version 3.0, with only the Ajax function.

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

In short, continue using $("iframe").on("load"... to load content into the div that is not obsolete. What became obsolete, as of version 1.8, was the use of .load() as an event.

    
01.12.2018 / 20:21