Flask send_file as attachment not working
This is not a flask related question.It's how browsers and javascript works.
You're downloading the file in Ajax so the result is passed to your Ajax callback.
You want instead to make the browser download data in his usual way.
To do so you must use a form
and call the .submit()
method on it.Just create the form
in the page with hidden fields and submit it in the javascript function. It should do the trick.