1
I’m trying to make a system of load
to inform the user that the page is being loaded.
I have a php page that mounts a very large report, and it takes around 10 seconds to display. On how much this page turns blank. What I want is to put a load
until the page is loaded.
I tried to do so, at the beginning of php I put this:
<div class="se-pre-con"><p>PROCESSANDO DADOS</p></div>
I put before the tag
.se-pre-con {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 1000;
background: url(../Img/Loading.gif) center no-repeat #FFFFFF;
}
.se-pre-con p {
text-align: center;
height: 15px;
position: absolute;
top: 0;
bottom: -125px;
left: 0;
right: 0;
margin: auto;
}
No jquery looks like this:
$(window).on("load", function () {
$(".se-pre-con").fadeOut();
});
The problem is that the load even appears, but it appears after about 5 seconds. How do I make it appear and then php starts loading the data? Is there a way?
------------ EDIT
Follow my php page, so you can tell me if I’m doing something wrong.
<!-- Loading -->
<div class="se-pre-con"><p>PROCESSANDO DADOS</p></div>
<?php
// AQUI ESTOU CONECTANDO COM O BANCO DE DADOS E MONTANDO UM ARRAY COM O RESULTADO
?>
<!-- Relatório -->
<table class="relatorio">
<tr>
<td>ID</td>
<td>PRODUTO</td>
<td>QUANTIDADE</td>
<td>VALOR</td>
</tr>
<?php
// Aqui monto o relatório com o array
foreach ($curva as $c) {
?>
<tr>
<td><?= $c['id'] ?></td>
<td><?= $c['nome'] ?></td>
<td><?= $c['qtd'] ?></td>
<td><?= $c['valor'] ?></td>
</tr>
<?php
}
?>
</table>
Already tried: $(Document). ready(Function () { }); ??
– Aline
Maybe the problem is the size of the gif, these 5 seconds can be the time it takes for the browser to load the gif, instead said try to put a <H1> just to test if it is rendered as soon as it loads the page
– LuKs Sys
Is using
ajax
?– Max Rogério
@I’m not using ajax
– Hugo Borges
@Lukssys already tried to remove the image, and the problem is not this.
– Hugo Borges
@Aline did not understand very well
– Hugo Borges
@Hugoborges, how many records are returned in this query to the bank? I see no reason for your page to delay, so the query may be the problem.
– jlHertel
@jlHertel the question not and the amount of registration, are several factors. I summarized the report to post here, but in it I do various calculations and checks in the database. This is a report with a lot of data so it takes a while.
– Hugo Borges
@Hugoborges, then it is suggested to load the blank page and bring the data later via AJAX. The only problem is that if it’s as much data as you said yourself, AJAX won’t be the solution. A third (uglier) option would be to load the report into an iframe, to allow the external page to be free to display the loading div you want.
– jlHertel
I don’t think iframe would be cool, I think AJAX would be the best solution. I liked your idea in AJAX, I just don’t know how to use it in my code. I don’t understand how I’m going to load the data in the table. Could you give a more detailed example?
– Hugo Borges