【问题标题】:jQuery File Download Plugin go always in fail functionjQuery File Download Plugin 总是失败功能
【发布时间】:2015-01-28 13:29:41
【问题描述】:

我正在使用这个插件通过 jquery 下载文件。 问题是当我正确下载文件时我也输入了失败功能。这是我的代码:

function openDownloadDialog(serialNumber) {
    //TODO gestire okButton per scaricare la chiave

    $.fileDownload("/async/paas/caaas/downloadCertificate/"+serialNumber)
    .done(function (url) { 
        $("#modalDownloadFailedCertificate").modal("hide");})
    .fail(function (responseHtml,url) {
        $("#modalDownloadFailedCertificate").modal("show");
    });
}

我该如何解决这个问题? 提前致谢

【问题讨论】:

  • 我的网络服务 /async/paas/caaas/downloadCertificate/ return true o false, FileDownload 需要什么?

标签: javascript jquery file download


【解决方案1】:

我已经通过 cookie 设置解决了:

response.setHeader("Set-Cookie", "fileDownload=true; path=/");

否则,如果我设置了异常:

response.setHeader("Set-Cookie", "fileDownload=false; path=/");

【讨论】:

  • 对于自定义 cookie,使用 addHeader 而不是 setHeader,因为 setHeader 会删除所有其他“Set-Cookie”标头
猜你喜欢
  • 2014-05-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-29
  • 2020-04-06
相关资源
最近更新 更多