I am facing an issue while trying to download a file using an Ajax request. Although the file is successfully downloaded, I am unable to open it. I am seeking assistance with the provided details below.
Thank you.
On a JSP page, there is a list of attachments, each accompanied by a Download button.
Upon clicking the Download button, a function named downloadFile(url) is called.
https://i.sstatic.net/5kM9o.png
The code on the Download button:
<button onclick= "downloadFile('ProcessControllerHelper?action=download&attachmentId=<%=attachment.getAttachmentId() %>')" class="btn btn-sm btn-round btn-default"><bean:message key="lbl.download"/></button>
The downloadFile function that is executed upon clicking the Download button:
function downloadFile(url)
{
// Code for downloading file
}
Despite successfully downloading the files upon clicking the Download button, they cannot be opened as shown in the screenshot below:
https://i.sstatic.net/bGF7D.png
The problem lies in the fact that the downloaded file cannot be opened, and an error message stating "we don't support the format" is displayed:
https://i.sstatic.net/Ar3od.png
Your help would be greatly appreciated!