-
-
Save edgardo001/c0ca5263dbc3fca7cb2dda574ac007b4 to your computer and use it in GitHub Desktop.
How to download file in base64 format by ajax request to your api
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
$.ajax({ | |
url: "http://api.yoursite.com", | |
data: data, | |
type: "POST" | |
}).done(function(result) { | |
var link = document.createElement("a"); | |
document.body.appendChild(link); | |
link.setAttribute("type", "hidden"); | |
link.href = "data:text/plain;base64," + result; | |
link.download = "data.zip"; | |
link.click(); | |
document.body.removeChild(link); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment