使用jquery.fileDownload.js(插件)下载文件 [英] File download using jquery.fileDownload.js (plugin)

查看:2387
本文介绍了使用jquery.fileDownload.js(插件)下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在尝试使用jquery.fileDownload.js插件,如 DEMO

我的代码如下 -

 <   script     src   =  js / jquery.fileDownload.js >  <   /   script  >  
< script 类型 = text / javascript >

$( doc ument )。on( click a.myClass1 function (){
$ .fileDownload ($( this )。prop(' href'),{
PreparingMessageHtml: 我们正在准备您的报告,请稍等......
failMessageHtml: 生成报告时出现问题,请重试。
});
return false ; // 这是至关重要的
});
< / script >

< / head >

< 正文 >
< a class = myClass1 href = http:// myServer:6024 / sites / abc / TechDocs / CSE / 111.zip > 在此下载< / a >





问题是,它显示的是failmessageHtml jquery dailog然后在点击链接时进行正常下载。

有没有人用这个插件下载文件?我正在做什么错误?

任何关于这个问题的帮助都表示赞赏。



问候,

Sayan 。

解决方案

document )。on( 单击 a.myClass1 function (){


.fileDownload(


this )。prop(' href'), {
PreparingMessageHtml: 我们正在准备您的报告,请稍候......
failMessageHtml: 生成报告时出现问题,请重试。
});
return false ; // 这是至关重要的
});
< / script >

< / head >

< 正文 >
< a class = myClass1 href = http:// myServer:6024 / sites / abc / TechDocs / CSE / 111.zip > 在此下载< / a >





问题是,它显示的是failmessageHtml jquery dailog然后在点击链接时进行正常下载。

有没有人用这个插件下载文件?我正在做什么错误?

任何关于这个问题的帮助都表示赞赏。



问候,

Sayan


Hello,
I am trying to use the jquery.fileDownload.js plugin as in this DEMO.
My code is as follows--

  <script src="js/jquery.fileDownload.js"></script>
  <script type="text/javascript">

  $(document).on("click", "a.myClass1", function () {
    $.fileDownload($(this).prop('href'), {
        preparingMessageHtml: "We are preparing your report, please wait...",
        failMessageHtml: "There was a problem generating your report, please try again."
    });
    return false; //this is critical
});
  </script>

 </head>

 <body>
 <a class="myClass1" href="http://myServer:6024/sites/abc/TechDocs/CSE/111.zip">Download Here</a>



The problem is, its displaying the failmessageHtml in jquery dailog and then proceeds to normal download as it happens on clicking the link.
Has anyone used this plugin to download file? What mistake I'm doing?
Any help regarding the problem is appreciated.

Regards,
Sayan.

解决方案

(document).on("click", "a.myClass1", function () {


.fileDownload(


(this).prop('href'), { preparingMessageHtml: "We are preparing your report, please wait...", failMessageHtml: "There was a problem generating your report, please try again." }); return false; //this is critical }); </script> </head> <body> <a class="myClass1" href="http://myServer:6024/sites/abc/TechDocs/CSE/111.zip">Download Here</a>



The problem is, its displaying the failmessageHtml in jquery dailog and then proceeds to normal download as it happens on clicking the link.
Has anyone used this plugin to download file? What mistake I'm doing?
Any help regarding the problem is appreciated.

Regards,
Sayan.


这篇关于使用jquery.fileDownload.js(插件)下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆