如何在php上传时显示加载画面?

时间:2018-05-19 08:54:53

标签: php mysql

我尝试在php上传时加载屏幕,请帮帮我

$con = mysqli_connect("localhost","user","password","db_name");
// Check connection
if (mysqli_connect_errno())
{
 echo "Failed to connect to MySQL: " . mysqli_connect_error();
 }
  $current_date = date("h:i:sa");
  $date_title = "TODAY";     
  $update_query1 = "insert into date(date_title, date) values('$date_title', '$current_date')";
  if(mysqli_query($con,$update_query1)){
  echo "<script>alert('Comments has been published')</script>";
  echo "<script>window.open('load.php','_self')</script>";
 }

2 个答案:

答案 0 :(得分:2)

您可以使用以下代码在提交数据期间显示加载程序

<form method="post" onsubmit="return showoverlay();">
    <div id="overlay" hidden>
        <i class="fa fa-spinner fa-spin spin-big"></i>
    </div>
    Your HTML Design Code here.
</form>

<script>
    function showoverlay() {
       $('#overlay').prop('hidden',false);
       $('#overlay').css({"display": "table"});
    }
</script>

这段代码可能对您有用。

答案 1 :(得分:1)

用户点击上传按钮,在屏幕中显示Loading...。上传成功后,将Loading...更改为Success

使用AJAX。