Skip to main content
Inspiring
February 15, 2019
Answered

CFLocation after CFFlush

  • February 15, 2019
  • 2 replies
  • 650 views

Hello,

I need to make a user pause for 5 seconds when another user is completing a particular task. I can't figure out why my cflocation tag doesn't execute after the cfflush is done. If I remove the cffush it works. What am I missing?

Thanks in advance for any assistance.

<style>

.loader {

  border: 16px solid #f3f3f3;

  border-radius: 50%;

  border-top: 16px solid blue;

  border-right: 16px solid green;

  border-bottom: 16px solid red;

  border-left: 16px solid pink;

  width: 120px;

  height: 120px;

  -webkit-animation: spin 2s linear infinite;

  animation: spin 2s linear infinite;

}

@-webkit-keyframes spin {

  0% { -webkit-transform: rotate(0deg); }

  100% { -webkit-transform: rotate(360deg); }

}

@14668356 spin {

  0% { transform: rotate(0deg); }

  100% { transform: rotate(360deg); }

}

</style>

<cfflush>Please Wait. Another user is creating a configuration file.<br>

<div class="loader"></div>

<cfflush>

<cfscript>

thread = CreateObject("java","java.lang.Thread");

thread.sleep(5000);

</cfscript>

<cfflush>

Done!

<cflocation url="../home.cfm" addtoken="no">

why didn't it load?!?

    This topic has been closed for replies.
    Correct answer Dave Watts

    You can't use CFLOCATION after CFFLUSH. This is not a CF issue, it's just how HTTP works. CFFLUSH returns the HTTP response headers along with part of the HTTP response body (the page). CFLOCATION returns a specific HTTP response header telling the browser to go to another page. By the time you're displaying part of the body of the page, it's too late to tell the browser to go to another page using HTTP response headers.

    Dave Watts, Eidolon LLC

    2 replies

    ghanna1Author
    Inspiring
    February 15, 2019

    Thanks!  I was able to achieve what I needed with a javascript redirect.

    <script type="text/javascript"> 

        function Redirect()

        {

            window.location="http://www.google.com";

        }

        document.write("Trying Again");

        setTimeout('Redirect()', 1000); 

    </script>

    Dave WattsCommunity ExpertCorrect answer
    Community Expert
    February 15, 2019

    You can't use CFLOCATION after CFFLUSH. This is not a CF issue, it's just how HTTP works. CFFLUSH returns the HTTP response headers along with part of the HTTP response body (the page). CFLOCATION returns a specific HTTP response header telling the browser to go to another page. By the time you're displaying part of the body of the page, it's too late to tell the browser to go to another page using HTTP response headers.

    Dave Watts, Eidolon LLC

    Dave Watts, Eidolon LLC