分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 技术分享

jquery.fileDownload plugin: Success msg alert before actual pdf download completed

发布时间:2023-09-06 01:15责任编辑:顾先生关键词:pdf

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

原文地址:http://www.cnblogs.com/uu5666/p/7629476.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved