Page 1 of 1
how to display waiting message/image while parsing a file
Posted: Mon Apr 27, 2009 7:22 am
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
Re: help?
Posted: Mon Apr 27, 2009 7:42 am
by Apollo
See
nr.7
Regarding your question, this may help:
But it doesn't work everywhere (depends on server). Instead of flush, you can also try
ob_flush, or both.
Re: help?
Posted: Mon Apr 27, 2009 10:47 pm
by mymykeviv
Apollo wrote:See
nr.7
Regarding your question, this may help:
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.
Re: help?
Posted: Mon Apr 27, 2009 10:59 pm
by Benjamin

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.
Re: help?
Posted: Tue Apr 28, 2009 2:21 am
by mymykeviv
astions wrote:
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
Re: how to display waiting message/image while parsing a fil
Posted: Tue Apr 28, 2009 3:20 pm
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.