Skip to content

Instantly share code, notes, and snippets.

@AxelUser
Last active January 26, 2024 09:12
Show Gist options
  • Save AxelUser/e080e793143f10dcc52c0e543282d5fe to your computer and use it in GitHub Desktop.
Save AxelUser/e080e793143f10dcc52c0e543282d5fe to your computer and use it in GitHub Desktop.
How to download file in base64 format by ajax request to your api
$.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);
});
@mehmetbaz
Copy link

how much I can thank you

@GussSoares
Copy link

thanks!!!

@pablogonzalezz
Copy link

nice

@FqKeR3m1
Copy link

Thank you ! Exactly what I was looking for !

@artakabraham
Copy link

Thanks

@RHAF05
Copy link

RHAF05 commented Apr 23, 2022

Thanks for your code.

@oulina
Copy link

oulina commented Apr 30, 2023

Thanks!

@gfnew
Copy link

gfnew commented Jul 4, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment