Unstoppable Domains

[JS/AJAX?] Please Wait, Loading...

Spaceship Spaceship
Watch

Tree

Established Member
Impact
9
I have a rather large function that executes at a point on my site. It calculates the number of projected users using a complex and rather lengthy algorithm. This can take up to 30 seconds to execute.

How can I display "Please Wait, Future User Projection is Being Calculated." until all the calculations are finished?

The message should only be displayed in a table on the page.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
PHP:
<?php 
echo "<div id=\"hidelater\">Please Wait, Future User Projection is Being Calculated.</div>";
ob_flush(); flush();

//your algorythm here

echo "<script>document.getElementById(\"hidelater\").style.display = 'none';</script>";
?>

That should work.
 
0
•••
Alright, let me try it real quick. Thanks, Jim_!

It does! Thank you! :)

Sadly:

We're glad that you're fond of this member, but please give some rep points to some other members before giving it to Jim_ again.

:(
 
0
•••
That error message made me smile.
 
0
•••
Any way I can make this so that if it executes for more than 10 seconds have it display another message saying
This can take quite a long time if the selected date range is large. Please be patient.

The code for the large algorthm thing is
PHP:
BIG($_POST['Fday'],$_POST['Fmonth'],$_POST['Fyear'],$_POST['Tday'],$_POST['Tmonth'],$_POST['Tyear'],$_POST['location'],$_POST['ageF'],$_POST['ageT'],$_POST['gender']);
 
0
•••
echo "<div id=\"hidelater\">Please Wait, Future User Projection is Being Calculated.</div>";

replace that^ with this:
PHP:
echo "<div id=\"hidelater\">Please Wait, Future User Projection is Being Calculated.</div>
<script>
function tensecs() { document.getElementById(\"hidelater\").innerHTML = 'This can take quite a long time if the selected date range is large. Please be patient.'; }
window.setTimeout('tensecs()',10000);</script>";
 
0
•••
Jim_,

I love you.

Whoop, nevermind. Now the message doesn't go away once the function is done. Here's my current code:

PHP:
// Special thanks to Jim_ from NamePros.com
echo "<div id=\"hidelater\"><b><img src='pages/style/loadingcircle.gif'>  Please Wait, Future User Projection is Being Calculated.</b></div>
<script>
function tensecs() { document.getElementById(\"hidelater\").innerHTML = '<b><img src='pages/style/loadingcircle.gif'>  This can take quite a long time if the selected date range is large. Please be patient.</b>'; }
window.setTimeout('tensecs()',10000);</script>"; 
ob_flush(); flush();

BIG($_POST['Fday'],$_POST['Fmonth'],$_POST['Fyear'],$_POST['Tday'],$_POST['Tmonth'],$_POST['Tyear'],$_POST['location'],$_POST['ageF'],$_POST['ageT'],$_POST['gender']);

echo "<script>document.getElementById(\"hidelater\").style.display = 'none';</script>";
 
Last edited:
0
•••
try this:
PHP:
 // Special thanks to Jim_ from NamePros.com
echo "<div id=\"hidelater\"><b><img src='pages/style/loadingcircle.gif'>  Please Wait, Future User Projection is Being Calculated.</b></div>
<script>
function tensecs() { document.getElementById(\"hidelater\").innerHTML = '<b><img src=\"pages/style/loadingcircle.gif\">  This can take quite a long time if the selected date range is large. Please be patient.</b>'; }
window.setTimeout('tensecs()',10000);</script>"; 
ob_flush(); flush();

BIG($_POST['Fday'],$_POST['Fmonth'],$_POST['Fyear'],$_POST['Tday'],$_POST['Tmonth'],$_POST['Tyear'],$_POST['location'],$_POST['ageF'],$_POST['ageT'],$_POST['gender']);

echo "<script>document.getElementById(\"hidelater\").style.display = 'none';</script>";
 
0
•••
Nope :-/
 
0
•••
The only way I could think of doing it would be AJAX and using readystate..
 
0
•••
How would that be coded? Sorry, my AJAX is not so good.
 
0
•••
Dynadot — .com TransferDynadot — .com Transfer

We're social

Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back