Created
January 29, 2021 12:41
-
-
Save facugon/c41ec8f55aaca0f957f4149710c4b906 to your computer and use it in GitHub Desktop.
ajax file download
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
/** | |
* create a link and force download | |
*/ | |
function forceDownload () { | |
var a = document.createElement('a'); | |
var url = window.URL.createObjectURL(data); | |
a.href = url; | |
a.download = 'myfile.pdf'; | |
document.body.append(a); | |
a.click(); | |
a.remove(); | |
window.URL.revokeObjectURL(url); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment