Copy link to clipboard
Copied
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); }
}
@keyframes 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?!?
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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>