我的应用程序正在做大量的数据库查询,它保持加载页面空白,而做它。我想知道是否有办法在查询过程中显示加载图标。
<?php
//large queries
//if all queries pass
//do the redirect
header('Location: index.html');
//else show login screen.
?>
<html>
//show login screen….
</html>
我的问题是如何显示加载图标时,php查询数据库
谢谢。
- 将用户重定向到正在加载的页面向实际的内容脚本发出ajax请求(完成繁重的工作)当内容准备好时,用实际内容替换部分加载页面
加载页面的示例:(index.php返回页面body -element的内容)
<script>
$(document).ready(function() {
$.get("index.php", function(data) {
$("body").html(data);
console.log("page was loaded");
});
});
</script>
<html>
<body>
page is loading // <- shown while loading the page
</body>
</html>
注意:上面的例子期望包含jquery