【问题标题】:jquery filedownload not able to downloadjquery filedownload无法下载
【发布时间】:2017-06-17 07:42:27
【问题描述】:

我正在尝试在我的代码中实现 jquery 文件下载,但它没有按预期工作我使用本地系统作为我的文件系统来下载文件有人可以帮助我吗?我是 jquery 的新手,或者提供一个工作代码.

$(document).on("click", "a.fileDownloadSimpleRichExperience", 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 to stop the click event which will trigger a normal file download!
});


</script>


<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<a href="E://Download/Anshuman.txt" class="fileDownloadSimpleRichExperience">Download</a>

</body>
</html>

【问题讨论】:

  • 控制台上的任何错误消息??

标签: jquery


【解决方案1】:

你试过这样吗:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<a href="E://Download/Anshuman.txt" class="fileDownloadSimpleRichExperience">Download</a>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).on("click", "a.fileDownloadSimpleRichExperience", function (e) {
  e.preventDefault();
 var hiddenElement = document.createElement('a');
hiddenElement.href = $(this).attr('href');
hiddenElement.download = 'aaa.csv';
hiddenElement.click();

});



</script>
</body>
</html>

【讨论】:

  • 2017 年 6 月 17 日上午 11:52:44 org.apache.tomcat.util.digester.SetPropertiesRule 开始警告:[SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source ' 到 'org.eclipse.jst.jee.server:Filedownload' 没有找到匹配的属性。 2017 年 6 月 17 日上午 11:52:44
  • 仍然无法正常工作@Riaz Laskar 我已经发布了我遇到的错误。
  • 您好,有人有 jquery $.filedownload 和 struts2 实现工作代码吗??
  • 现在您的代码正在下载,但出现网络错误消息失败。请查看此
  • 你在服务器上运行它吗??
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-11-01
  • 1970-01-01
  • 2018-11-04
  • 2020-05-02
  • 2021-12-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多