Skip to content

Instantly share code, notes, and snippets.

@RHAF05
Created April 23, 2022 03:31
Show Gist options
  • Save RHAF05/52bafe6ef7c189cd4c8487fb0ee1e083 to your computer and use it in GitHub Desktop.
Save RHAF05/52bafe6ef7c189cd4c8487fb0ee1e083 to your computer and use it in GitHub Desktop.
How to download file in base64 format using ajax request
$.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