[英]how to put loading icon before the page loads
I have the following piece of code which is triggered by a button click.我有以下一段代码,它是由单击按钮触发的。
<?php
if(isset($_POST['click']))
{
echo "<div class='spinner-grow' role='status'>";
echo "<span class='sr-only'>Loading...</span>";
echo "</div>";
shell_exec("perl myscript1.pl");
shell_exec("perl myscript2.pl");
echo "<div class='image'>";
echo "<img src='figure.png' class='mx-auto d-block' style='width:800px; height:800px;'>";
echo "</div>";
}
?>
the perl scripts inside that block will generate a image which i will load into page, but those two scripts take around 10s.该块内的 perl 脚本将生成一个图像,我将加载到页面中,但这两个脚本需要大约 10 秒。 So I am trying to put a boostrap spinner and have given a fadeout of 9.5s in jquery.
所以我试图放置一个 boostrap 微调器,并在 jquery 中给出了 9.5s 的淡出。
But the spinner and the image together load after 9.5s.但是旋转器和图像在 9.5 秒后一起加载。 The jquery code i am using is below.
我正在使用的 jquery 代码如下。 Kindly help what needs to be done.
请帮助需要做的事情。
$(function() {
$(".spinner-grow").fadeOut(9500, function() {
$(".image").fadeIn(500);
});
});
Thanks, Karthic谢谢,卡西奇
Add a div just after tag.在标签之后添加一个 div。
<div class="pre-loader"></div>
` <div class="pre-loader"></div>
`
$(window).load(function() { $(".pre-loader").fadeOut(); //or your loading icon wrapped in the pre-loader class });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.