Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery ajax get download file

$.get(
url: downloadUrl,
function(data) {

//after get the data, how to ask browser pop up to save file?
}
); 

data is content dumped by server side servlet. can be binary

like image 833
cometta Avatar asked Mar 04 '11 14:03

cometta


People also ask

Can we download file using AJAX?

Downloading PDF File on Button Click using jQueryInside the DownloadFile JavaScript function, the URL of the File is passed as parameter to the jQuery AJAX function. Inside the jQuery AJAX function, using the XmlHttpRequest (XHR) call, the PDF file is downloaded as Byte Array (Binary Data).


1 Answers

Don't use Ajax for this, just location = downloadUrl;

like image 163
Quentin Avatar answered Oct 12 '22 22:10

Quentin