how to display waiting message/image while parsing a file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mymykeviv
Forum Newbie
Posts: 3
Joined: Mon Apr 27, 2009 7:14 am

how to display waiting message/image while parsing a file

Post by mymykeviv »

hi guys...
i am new to php ,so please help me out.
i have this page where i have to parse text files for data an then display it in a table.
this much i have done succesfully.now i want to add a 'please wait' or some loading gif image while this parsing is bieng done.
but i dnt know how to do it?
can somebody help me
Last edited by mymykeviv on Tue Apr 28, 2009 2:20 am, edited 2 times in total.
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: help?

Post by Apollo »

See nr.7

Regarding your question, this may help:

Code: Select all

print('please wait');
flush();
But it doesn't work everywhere (depends on server). Instead of flush, you can also try ob_flush, or both.
mymykeviv
Forum Newbie
Posts: 3
Joined: Mon Apr 27, 2009 7:14 am

Re: help?

Post by mymykeviv »

Apollo wrote:See nr.7

Regarding your question, this may help:

Code: Select all

print('please wait');
flush();
But it doesn't work everywhere (depends on server). Instead of flush, you can also try ob_flush, or both.
Thanks for the help.
It is working ,but for files which have less data .if the data is too much my loading images is displayed just for few seconds and then it is gone and after a few more seconds my populated table appears.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: help?

Post by Benjamin »

:arrow: Moved to PHP - Code

Also, as Apollo insinuated:
Forum Rules wrote: 2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
mymykeviv
Forum Newbie
Posts: 3
Joined: Mon Apr 27, 2009 7:14 am

Re: help?

Post by mymykeviv »

astions wrote::arrow: Moved to PHP - Code

Also, as Apollo insinuated:
Forum Rules wrote: 2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
thanks for reminder...wont happen again
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: how to display waiting message/image while parsing a fil

Post by McInfo »

A demo:

The loadingPleaseWait div is a hidden overlay. When you click on the "Load Results Page" link, the "Loading, please wait..." message is visible until results-page.php returns something.

start-page.php

Code: Select all

<html>
<head>
<title>Start Page</title>
<style type="text/css">
#loadingPleaseWait {
    position: absolute; left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: white;
    display: none;
    }
#loadingPleaseWait div {
    margin-top: 10%;
    text-align: center;
    }
</style>
<script type="text/javascript">
function show_wait_msg ()
{
    get('loadingPleaseWait').style.display = 'block';
}
function hide_wait_msg ()
{
    get('loadingPleaseWait').style.display = 'none';
}
function get (id)
{
    return document.getElementById(id);
}
</script>
</head>
<body onload="hide_wait_msg()">
 
<div id="loadingPleaseWait"><div>Loading, please wait...</div></div>
 
<p><a href="results-page.php" onclick="show_wait_msg()">Load Results Page</a></p>
 
</body>
</html>
Note: The onload="hide_wait_msg()" in the body tag is unnecessary.

results-page.php

Code: Select all

<?php ob_start(); ?>
<html>
<head><title>Results Page</title></head>
<body>
<p>Loaded</p>
<?php sleep(5); /* Simulates work :) */ ?>
</body>
</html>
<?php ob_end_flush(); ?>
Bug: Because Firefox caches the Javascript state of pages, the start page will still show the wait message if you use the back button to return to it from the results page.

Edit: This post was recovered from search engine cache.
Post Reply