PHP: Display a “loading” page while a php script is executing

后端 未结 3 668
忘了有多久
忘了有多久 2021-01-16 02:14

Here is what I\'ve got right now...

I have a web page that when accessed, it connects to surveygizmo.com via their open API, retreives a whole lot of data, and then

相关标签:
3条回答
  • 2021-01-16 02:38
    <?php
    
         echo "Working...<br/>\r\n"; flush(); //output to the browser before the rest of the execution
    
         connect_surveygizmo(); //this is going to take while.
    
         echo "Finished!";
    
    ?>
    
    0 讨论(0)
  • 2021-01-16 02:54

    Create a loading page that displays your desired loading message. Then using ajax (I HIGHLY recommend jQuery) load a separate php file that loads the outside data. Once the data returns to your loading page, it's a simple task of hiding the loading message and replacing it with the output of the ajax.

    0 讨论(0)
  • 2021-01-16 03:01

    You'll want to take a look at AJAX. The solution is to send the browser a "loading" page, which contains javascript that shows the loading message, and then connects to the actual data generating server-side script asynchronously. When you have received and processed the data, you can insert it into the DOM and remove the loading message. Googling for XMLHttpRequest will get you the details.

    0 讨论(0)
提交回复
热议问题