On the click of a button I make an ajax call , a csv-file is created, and a link to the file is returned. On success, I want the file to download.
If on success I do:
window.open(output);
a new window opens and I can see the correct path to the file in the adress bar. But I get a 404 error, so it is interpreted as a page rather than a file download.
With html links you can use "download" to achieve a file download:
<a href="/path.jpg" download>
Is there some equivalent command in javascript to achieve this download?
------------------------Edit:-----------------------------
It turned out that
window.open(output);
works fine! I used the file system path instead of the URL - I needed to use the url. Now when I click the button, the file downloads at the ajax success method.
(if this question is not unique I can delete it if you think so)