0

I don't know if this can be achieved but I'm aking because I find this kind of page transition on many websites. My questions are 2 and the following

Is that possible to make appear a loader (gif) before html is loaded and during a page transition?

And if yes,

Is that possible doing it through jQuery, AJAX and PHP?

I mean, I know how to implement a loader on page load like:

<div class="loader"><!-- whatever animated gif--></div>
<script>
   $(window).load(function() {
      $(".loader").fadeOut("slow");
   })
</script>

But at this way, I see before a white screen, then loader and next the full page. My question is about displaying a loader before the page is changing and loading, like:

  1. Click on link;
  2. Bam: Loader displayed;
  3. Bam: page changes and loads in background.
  4. Loader disappears.

Different by this question which is referring to AJAX calls. I'm talking about html or php whatever page.

Community
  • 1
  • 1
middlelady
  • 573
  • 2
  • 13
  • 36
  • You can try to display load indicator as first in html and just after call `` http://php.net/manual/pl/function.flush.php – jcubic May 17 '16 at 15:42
  • @jcubic thanks for your reply! Could you provide an answer to make me understand better? – middlelady May 17 '16 at 15:44

1 Answers1

0

You can try to use flush php function just after your ajax indicator

<!DOCTYPE html>
<html>
<body>
<div class="loader"><!-- whatever animated gif--></div>
<?php flush(); ?>
rest of the html
</body>
</html>
jcubic
  • 61,973
  • 54
  • 229
  • 402