繁体   English   中英

在重定向时显示加载图像

[英]Show loading image on redirection

我有两个页面 x.php 和 y.php,我将页面 x.php 重定向到 y.php。 我正在通过表单发布方法重定向页面。

y.php 正在从 mysql 数据库中提取更多数据,加载该页面需要 3 到 4 秒,我需要在页面加载时显示进度条(加载图像)。

这就是我正在做的

一个 html 页面正在提交到远程服务器 x.PHP 页面,x.PHP 页面正在从 mysql 数据库中提取数据,并根据它重定向到 y.PHP 的数据类型,这种重定向是通过使用 Javascript 自动提交表单来完成的。

我需要在 html 到 x.php 和 x.php 到 y.php 上显示加载图像。

我尝试在 x.PHP 页面顶部回显图像标签,它在 Mozilla 中工作,而不是其他浏览器。

我怎样才能做到这一点; 谁能帮我?

希望能帮助到你

<style>
    .loader {
        position: fixed;
        left: 0px;
        top: 0px;
        width: 100%;
        height: 100%;
        z-index: 9999;
        background: url('images/somegif.GIF') 50% 50% no-repeat rgb(249,249,249);
    }
    </style>
    <script>
        $(window).load(function() {
            $(".loader").fadeOut("slow"); 
        })
    </script>
    <body>
    <div class="loader"></div>
    </body>

我认为唯一的方法是使用 AJAX - 在 x.php 上加载 y.php,或在 y.php 上加载数据。

你需要使用jquery。 我正在使用此代码。

当您的请求开始将加载图像加载到页面时。 当数据返回成功函数时,它将数据加载到页面。

    $('#something').change(function(){ // change, click doesnt matter



    $('#load').html("<img src='images/load2.gif' />"); // loading img



    $.post(
            'select.php?do=load', // your y.php
            {s:value},
            function(answer){

            $('#load').html("");
            $('#page').html(answer);


            }
    );

});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM