Reputation: 75
My application uses ExtJs as front end ans Spring MVC+Hibernate JPA as backend. I need to download a file. The url of the document is retrieved using the AJAX request.there is a Download button, and when the user clicks it, there should be an option for Save As.
var body = Ext.getBody();
var form = body.createChild({
tag:'form'
,cls:'x-hidden'
,id:'form'
,action:'document/download/'+selDocument.data.documentId
,target:'iframe'
});
form.dom.submit();
This code is working fine for me now. The only problem is that the page gets refreshed when I click download. Is there any way to avoid that?
Upvotes: 0
Views: 1160
Reputation: 13475
Probably the quickest way of doing that would be to spawn a new window with the URL of the download as the target..
window.open(url);
The browser will open a new window, show the download dialog control and then close the window.
Upvotes: 1