2
Hello, I have the following code snippet below:
Code
div#container{
position:absolute;
width: 100%;
height: 100%;
top: 0px;
left:0px;
background-color: #eee;
display: block;
}
div#loader{
border: 16px solid #f3f3f3; /* Light grey */
border-top: 16px solid #3498db; /* Blue */
border-radius: 50%;
width: 120px;
height: 120px;
animation: spin 2s linear infinite;
position: fixed;
top: 0px;
left:0px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>PÁGINA LOAD</title>
<link rel="stylesheet" href="css/style.css" media="screen"/>
<script src="js/jquery-2.1.3.js"></script>
</head>
<body>
<div id="container">
<div id="loader"></div>
<div id="content">
<p>Exibir meu código PHP aqui após o carregamento total da página</p>
</div>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://raw.githubusercontent.com/jsor/jcarousel/master/dist/jquery.jcarousel.min.js"></script>
<script type="text/javascript">
// Este evendo é acionado após o carregamento da página
$(window).on('load', function(){
//Após a leitura da pagina o evento fadeOut do loader é acionado, esta com delay para ser perceptivo em ambiente fora do servidor.
jQuery("#loader").delay(2000).fadeOut("slow");
});
</script>
</body>
</html>
Goal
I would like my PHP content to be displayed on the screen only after loading 100% because this PHP snippet is a select
in the database that takes a long time to display giving aspect that the page is not responding.
Problem
The Loader is always displayed next to the PHP content, so it is only displayed after the request is finished. I tried several ways before posting on the forum, if someone can show a method that works will be of great help!
The Loader should disappear only when the PHP code is inserted into the HTML?
– Victor Carnaval
I believe you should use Ajax to load only the content of div #content.
– Sam
Exactly @Victorcarnaval
– buddy-stack
How can I do this @Sam? Could you give me an example please!
– buddy-stack