Running Tasks Before Redirect
We have a timer process (a JQuery plugin) that redirects after X number of minutes to the login page, all via JavaScript. When the timer hits zero, I want to run a task (could be anything; however, in this specific scenario, it's a web service call).
So the process does:
if (zeroedOut) {
window.setTimeout(function() {
//Run finish-up processes
}, 0);
window.location = "login.aspx";
}
The issue I'm having is the web service that runs with the finish-up processes is not being called. The 开发者_如何学Pythonweb service call happens, the redirect happens, I don't see any errors (I have try/catch statements around the setTimeout call), but no WS call.
Has anybody got this to successfully work? What might I be missing here?
Thanks.
Why isn't your redirect in the setTimeout
call? Otherwise, the redirect will happen before the queued code can run.
if (zeroedOut) {
window.setTimeout(function() {
//Run finish-up processes
window.location = "login.aspx";
}, 0);
}
精彩评论