jquery.fileDownload plugin: Success msg alert before actual pdf download completed
Posted mike11
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jquery.fileDownload plugin: Success msg alert before actual pdf download completed相关的知识,希望对你有一定的参考价值。
Currently , I use jquery fileDownload plugin to download multiple pdf that in a list page, which every single hyperlink can download one pdf file.
When i click 1st link, every thing occured ok, but when click 2nd or other link, success msg alert before actual pdf download completed. It confused me a few days...
Finally, i find the reason and got a way to resolve the problem.
We can check source code in jquery.filedownload.js, when document.cookie contains value ‘fileDownload=true‘, it will pop up success msg. The key is when finish the 1st download, the cookie not expired!!! So when you click second ,third link,msg alert before download.
I tried set cookie ‘s maxAge ,but it still same error..
The thing we do is every download we need create a unique cookie.
Thanks http://gruffcode.com/2010/10/28/detecting-the-file-download-dialog-in-the-browser/,
We can generating a token value using the current timestamp as the value of ‘filedownload‘, This token can really be any arbitrary string value, but we do want to try and make it unique per request coming from the same browser, and using the timestamp is a pretty easy way to do this. We take that token and add it to the form within that hidden field that we created. This will ensure that the token value gets submitted up to the server (more on this later).
以上是关于jquery.fileDownload plugin: Success msg alert before actual pdf download completed的主要内容,如果未能解决你的问题,请参考以下文章
Safari 添加 .html 以使用 epplus jquery.fileDownload.js 下载 xlsx
jQuery fileDownload 插件不显示弹出窗口,如何解决这个问题?
使用xlwt创建Excel文件并插入对有效的响应jquery.fileDownload文件下载
jquery.fileDownload plugin: Success msg alert before actual pdf download completed
webpack5以上版本 使用optimize-css-assets-webpack-plugin压缩问题
Caused by: java.nio.file.NoSuchFileException: /Volumes/software/elasticsearch-6.4.3/plugins/ik/plugi