<!--- **************************** --->
<!--- application.cfm --->

<cfapplication name="wait-test"
                    clientmanagement="no"
                    sessionmanagement="no">

<!--- **************************** --->
<!--- wait.cfm --->

<html>
  <head>
    <title>Please Wait Message</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  </head>

  <body>
  <p>
You can use a combination of &lt;cfflush&gt; and javascript to show a message on the screen while processing a large data set (or any other long-running task).</p>
  <!--- use cfflush to display the 'wait' message right away --->
  <cfflush interval="1">
  <!--- show the message saying there will be a delay --->
  <p id="wait" style="color:red; background-color: #CCCCCC; width: 200px; height: 50px;">Please wait while the data is processed.</p>

  <!--- process your long-running query or script (or anything) --->
  <cfset total = 0>
  <cfloop from="1" to="10000" index="i">
    <cfset total = total + 1>
  </cfloop>

  <!--- after the process is done, use javascript to remove the 'wait' message --->
  <script>
    if (document.getElementById) {
          wait.style.display="none";
    }
  </script>
  <!--- now display the result --->
  <p>The total is<cfoutput>#total#</cfoutput>.</p>

  <p>Keep in mind that this may not work if you have a lot of nested tables since ColdFusion can't
return results unless the ending tags can be flushed as well.</p>

  </body>
</html>

About This Tutorial
Author: Nathan Miller
Skill Level: Beginner 
 
 
 
Platforms Tested: CFMX
Total Views: 145,104
Submission Date: January 13, 2004
Last Update Date: June 05, 2009
All Tutorials By This Autor: 11
Discuss This Tutorial
  • Hi - i wondered if cfflush would be the answer rto my problem here - i haven't yet managed to get it working.. I have an image upload form and once the form is submitted, the filename is written to the database and the image is resized into large and thumbnail versions. This can take some time, so I wanted to display a 'please wait' at the very least, while this is executing. While the form is submitted and the image data is sent to the server there is apparently little I can do, but after that, once the form data is fully submitted and before the other scripts write to the database etc I would like the message to appear. I currently have this:

    PLEASE WAIT!!

    ****IMAGE HANDLING AND DATABASE SCRIPTS****** To try and flush the message

    before the scripts are dealt with. It doesn't work - could you help? thanks Ian

Advertisement


Website Designed and Developed by Pablo Varando.