Javascript AJAX file download

Is it possible to do something like this?

$.post( '/generate/file', json_data_striginfied, function( data ) { var win = window.open() window.write(data) }); 

where is the binary data returned (pdf file)?

I tried this, and a new window contains binary data as text, this does not force loading. I would like it to force the download of a PDF file.

+4
source share
1 answer

Try adding the remote PDF url to the source URL of the new window.

0
source

All Articles