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.
can detail more about how you are entering the data in the div?
– Matheus
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.– Douglas Garrido
Put your code.
– Diego Souza
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 viajs
?– Leonardo Rodrigues
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.
– ayelsew
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.
– Renato Diniz