Skip to main content
Inspiring
Feb 15, 2019 4:42 PM UTC
Answered

CFLocation after CFFlush

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 is closed to new replies. Start a new post to keep the conversation going.
    Dave WattsCorrect answer
    Community Expert
    Feb 15, 2019 4:47 PM UTC

    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

    2 replies

    ghanna1Author
    Inspiring
    Feb 15, 2019 5:10 PM UTC

    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>

    Translate
    Dave WattsCommunity ExpertCorrect answer
    Community Expert
    Feb 15, 2019 4:47 PM UTC

    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

    Translate
    Dave Watts, Eidolon LLC