I
I
ILoveYAnny2017-04-14 10:34:30
JavaScript
ILoveYAnny, 2017-04-14 10:34:30

Is it possible to download a file using jQuery similar to the Link attribute?

Hello, does anyone have experience downloading a file through JS?
The task is as follows: you need to press the button, after which the download with the name "example" will begin, and not opening a window with mp3 listening. In other words, analog

<a href="/file.mp" donwload="example.mp3" id="download">Download link</a>

Click with jQuery does not work I so suspect that due to the security policy, the click is not caught. How can this problem be solved?
$("#download").click();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sasha, 2017-04-14
@ILoveYAnny

the server should return the header that this is a file to download

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question