You are here: Re: howto: please wait, this may take a few seconds... « PHP Programming Language « IT news, forums, messages
Re: howto: please wait, this may take a few seconds...

Posted by Sacs on 09/22/05 04:48

Erwin Kloibhofer wrote:
> what if i have a webpage that displays the text "please wait, this may take
> a few seconds..." and it now waits until some event on the server happens.
> whatever this is, this can be quick, but it could also be slow, or it can
> even fail. but once this event has happened, i want the webpage to reload
> and display a different message, like "the process completed successfully".
>
> my question now is, how would i achieve this without constant visible
> reloads? (which would probably be the simplest solution). is there a way to
> do invisible polling via maybe a javascript (somewhere i picked up that
> "ajax can do that")? what i want to achieve is that only if the event i was
> waiting for actually occured, i want the webpage to actually visibly
> reloaded, and displaying the new message.
>
> what approach do for instance professional payment systems take, while the
> client is waiting if the credit-card number is valid?
>
> can someone push me in the right direction?
>
>

You could use the onload() function in the <BODY> to redirect once the
page has finished, or use php to inject some javascript once your
processing is done, or get a little clever with the CSS visibility
property.

<html>
<head>
<style>
#waiting {
width: 100%;
height: 100%;
}
</style>
<script language=javascript>
function hide() {
h = eval('document.getElementById(\'waiting\')');
h.style.visibility = "hidden";
h.style.height = "0%";
}
</script>
</head>
<body onload="hide();">
<div id="waiting">
<center><br>
This may take a while!
</center>
</div

<?php

flush();
echo "doing something...... <br>";

sleep(10);

echo "Done <br>";
?>

Sacs

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация