right now we are using href to link to downloadfile.asp with the parameters so we have a browser window opens.
is it possible with jquery/ajax?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using AJAX you could fetch the remote resource but the file will be represented by a byte array you won’t be capable of doing much with it in javascript. You can’t save it to the user’s computer. Think of it this way: if this was possible you would be able to store EXEcutables on the user computer without him realizing which is kinda bad idea, don’t you think so?
That’s why it is more common to provide normal links to download files so that the user gets a Save As… dialog and decides where does he wants to store the file on his computer. Just make sure to set the proper
Content-Dispositionheader on your server:or
The difference is that with the first the user gets the Save As… dialog and with the second the browser will try to display the file inside the navigator if there’s an appropriate plugin installed (example Adobe Reader for PDF files).