Created
June 22, 2012 17:30
-
-
Save adamrobbie/2974111 to your computer and use it in GitHub Desktop.
set a cookie on the response of the download request and have JavaScript to poll for that cookie. Once the download is ready to be served, the cookie will be available in JavaScript. To ensure working across various browser windows/tabs in the same sessio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function download() { | |
var token = new Date().getTime(); | |
var wait = document.getElementById("wait"); | |
wait.style.display = "block"; | |
var pollDownload = setInterval(function() { | |
if (document.cookie.indexOf("download=" + token) > -1) { | |
document.cookie = "download=" + token + "; expires=" + new Date(0).toGMTString() + "; path=/"; | |
wait.style.display = "none"; | |
clearInterval(pollDownload); | |
} | |
}, 500); | |
window.location = "download?token=" + token; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment