467,077 Members | 1,002 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

Sleep asynchronous?

JW
I wanted have this as part of a flood control script:
<?
echo ("Flood control in place - please wait " . $floodinterval . " seconds
between postings.");

sleep(5);
// go back two pages
echo "<script>window.history.go(-2);</script>";
exit;
?>

Problem is that the first echo never shows up on the page; it displays a blank
page (well, the page constructed up to PHP section), then sleeps for the five
seconds and goes back two pages.

Why?

Thanks -

jon

--
jwayne@_myrealbox_no_spam.com
Jul 16 '05 #1
  • viewed: 4446
Share:
2 Replies
JW wrote:
I wanted have this as part of a flood control script:
<?
echo ("Flood control in place - please wait " . $floodinterval . " seconds
between postings.");

sleep(5);
// go back two pages
echo "<script>window.history.go(-2);</script>";
exit;
?>

Problem is that the first echo never shows up on the page; it displays a blank
page (well, the page constructed up to PHP section), then sleeps for the five
seconds and goes back two pages.

Why?


Could be caching is turned on with your web server. So you're spitting
out the notice, but the server is holding all your output until the
script is done. In which case the browser gets the <script> and
executes it right away, before you can see the notice posted on the page.

You could have the script execute with a

<script language="javascript">
window.setTimeout('window.history.go(-2);', 5000);
</script>

which will tell the browser to wait 5 seconds before going back. Even
if caching is turned on, this should work.

Jason

Jul 16 '05 #2
JW
Jason Dumler <du*********************@netscape.net> wrote:
JW wrote:
I wanted have this as part of a flood control script:
<?
echo ("Flood control in place - please wait " . $floodinterval . " seconds
between postings.");

sleep(5);
// go back two pages
echo "<script>window.history.go(-2);</script>";
exit;
?>

Problem is that the first echo never shows up on the page; it displays a blank
page (well, the page constructed up to PHP section), then sleeps for the five
seconds and goes back two pages.

Why?


Could be caching is turned on with your web server. So you're spitting
out the notice, but the server is holding all your output until the
script is done. In which case the browser gets the <script> and
executes it right away, before you can see the notice posted on the page.

You could have the script execute with a

<script language="javascript">
window.setTimeout('window.history.go(-2);', 5000);
</script>

which will tell the browser to wait 5 seconds before going back. Even
if caching is turned on, this should work.

Worked like a charm! Thanks much...

jon
--
jwayne@_myrealbox_no_spam.com
Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

21 posts views Thread by Alo Sarv | last post: by
1 post views Thread by Julian Hershel | last post: by
6 posts views Thread by Thomas | last post: by
10 posts views Thread by syed | last post: by
reply views Thread by Bishoy George | last post: by
7 posts views Thread by davidst95@gmail.com | last post: by
4 posts views Thread by Frankie | last post: by
2 posts views Thread by =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.