Created
April 23, 2022 03:31
-
-
Save RHAF05/52bafe6ef7c189cd4c8487fb0ee1e083 to your computer and use it in GitHub Desktop.
How to download file in base64 format using ajax request
This file contains hidden or 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: "https://api.yoursite.com", | |
type: 'GET', | |
data: data, | |
}).done(function(res){ | |
var a = document.createElement('a'); | |
a.href = 'data:application/pdf;base64,' + res; | |
a.download = 'documents.pdf'; | |
document.body.append(a); | |
a.click(); | |
a.remove(); | |
toastr["success"]("Archivo multiple generado exitosamente","Exito"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment