Referring to this post I have this scenario
<html>
<head>
<script>
// Our countdown plugin takes a callback, a duration, and an optional message
$.fn.countdown = function (callback, duration, message) {
// If no message is provided, we use an empty string
message = message || "";
// Get reference to container, and set initial content
var container = $(this[0]).html(duration + message);
// Get reference to the interval doing the countdown
var countdown = setInterval(function () {
// If seconds remain
if (--duration) {
// Update our container's message
container.html(duration + message);
// Otherwise
} else {
// Clear the countdown interval
clearInterval(countdown);
// And fire the callback passing our container as `this`
callback.call(container);
}
// Run interval every 1000ms (1 second)
}, 1000);
};
// Function to be called after 5 seconds
function redirect () {
this.html("<a href='mypdf.pdf'>Donwload</a>");
window.location = "http://msdn.microsoft.com";
}
</script>
</head>
<body>
Now, after "<boby>"
tag I have an classic Asp response.write/flush like this:
<%
ToLoop = 29
for i = 0 to ToLoop
StartTimer = Timer 'define time in second from 12:00AM
if i = 1 then
Count_Start_Second = round(This_Loop_Timer * ToLoop) 'use round for integer a decimal number
response.write "<div id='countdown'></div>"
response.write"<script>" & _
"$('#countdown').countdown(redirect, " & Count_Start_Second & ", ""s remaining"");" & _
"</script>"
response.flush
end if
--------More and more asp code to compile a dinamic PDF----------
EndTimer = Timer 'define time in second after loop
This_Loop_Timer = EndTimer - StartTimer
next
%>
I don't understand why the jQuery is executed after the page has finished loading? With the Flush, theorically, should load immediately after the first lap of the loop. But isn't.