Skip to content Skip to sidebar Skip to footer

How To Check If Element Is Already Loaded Via Ajax?

I want to check if element is already loaded. HTML JS $(document).on('click','button',function () { $.ajax({ url: 'additional.html',

Solution 1:

you can do something like this:

$('body').bind("loaded", function () {
    alert('I see loaded element!');
});

$(document).on('click','button',function () {
  $.ajax({
    url: 'additional.html',
    context: document.body,
  }).done(function(html) {
    $('body').append(html);
    $('body').trigger("loaded");
  });
});

Or you can set jquery ajax to be sync, because it async as default.

Post a Comment for "How To Check If Element Is Already Loaded Via Ajax?"