Check if the contents of the div loaded

Asked

Viewed 647 times

2

It is possible to know if the content within the div charged with jquery? Equal to body.

I want to make a visual effect of the kind where an image of loading and only after the posting inside the div is fully loaded it will be displayed.

I searched the google but I can’t find anything about it. There’s no way ?

  • can detail more about how you are entering the data in the div?

  • You’re making an AJAX call and populating this div? If yes, it is easier to do this. But give more details than you need.

  • Put your code.

  • When you say charged, it would be a time of load until the content of the default div is fully visible, as in the case of an image? Or would it be content uploaded via js?

  • Example youtube when one of the videos that gets the side is chosen it changes the video that is playing in the player. My site has the same strategy when one of the posts next to it is chosen, it will be loaded to the div in the center of the page and in this action are loaded external pugins as comment systems and others. I would like only one loading image to be displayed during this period.

  • If you are loading with AJAX, it could display a loading message before the AJAX call, and in Success and Error of the call you would remove the message.

Show 1 more comment

1 answer

1

Hello, usually when you make calls like loading comments, this is done with ajax, so that the page is not reloaded when making the request.

Using ajax, you can place a div with a loading when you request [comments] and remove it when you’re done and populate the div with comments.

Below is an example:

HTML

<div id="comentarios"><img scr="loading.gif" /><\div>

JS

 $.ajax({
  url: "loadComentarios.php",
  context: document.body
}).done(function(data) {
  $('#comentarios').html(data);
});

Note that there is a done option in ajax. This is called when the request ends, and has as its parameter what was returned from your php (in this case, the comments). You remove the loading and replace it with the comment list.

Browser other questions tagged

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