页面加载前的jQuery Ajax加载器[重复]

时间:2021-07-26 05:01:11

This question already has an answer here:

这个问题在这里已有答案:

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

我不知道这是否可以实现,但我很喜欢因为我在许多网站上发现了这种页面转换。我的问题是2和以下

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

是否有可能在加载html之前和页面转换期间出现加载器(gif)?

And if yes,

如果是,

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

这有可能通过jQuery,AJAX和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. 点击链接;

  3. Bam: Loader displayed;
  4. Bam:装载机显示;

  5. Bam: page changes and loads in background.
  6. Bam:页面在后台更改和加载。

  7. Loader disappears.

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

不同的是这个问题指的是AJAX调用。我在谈论html或php的任何页面。

1 个解决方案

#1


0  

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

你可以尝试在你的ajax指标之后使用flush php函数

<!DOCTYPE html>
<html>
<body>
<div class="loader"><!-- whatever animated gif--></div>
<?php flush(); ?>
rest of the html
</body>
</html>

#1


0  

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

你可以尝试在你的ajax指标之后使用flush php函数

<!DOCTYPE html>
<html>
<body>
<div class="loader"><!-- whatever animated gif--></div>
<?php flush(); ?>
rest of the html
</body>
</html>