简体   繁体   中英

Show loading image on redirection

I have two pages x.php and y.php, I am redirecting the page x.php to y.php. I am redirecting the page by form post method.

y.php is pulling some more data from mysql database and it is taking 3 to 4 seconds to load that page, I need to show progress bar (loading image) while page loads.

This is what, I am doing,

a html page is submitting to remote server x.PHP page and x.PHP page is pulling data from mysql database and based on the type of data it redirects to y.PHP, this redirection is done by automatic form submit using Javascript.

I need to show loading image on both html to x.php and x.php to y.php.

I tried with echoing image tag on top of x.PHP page, it is working in Mozilla and not an other browsers.

How can I achieve this; can anyone help me?

Hope it helps

<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 上加载数据。

you need to use jquery. ı am using this code for that.

when your request start its load a loading image to page. when data return with success function it loading the data to page.

    $('#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);


            }
    );

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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