|
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]
|