Shaun Shaun - 4 months ago 12x
jQuery Question

Force download through js or query

Is it possible to force a download through JS or Javascript i-e the web page should not open the file in new tab in the browser but to pop up to let the user to choose eith "save as" or open with ???


You can not force that behavior from JavaScript, the HTTP Headers need to be set on the server side:


The way you can solve the problem is to let your AJAX method redirect the user to the URL of the PDF:


(The above HTTP headers must be set for the PDF)