dongwei1263 2015-03-24 09:20
浏览 168

TCPDF创建PDF需要花费太多时间,如何在此时显示加载效果

I have an anchor tag, with href to a page, where it will generate a PDF using TCPDF. It takes too much time to generate PDF. Meanwhile the interface page remain as such, it shows a loading icon on top of browser title bar. How can i show a loader on the interface, and this loader need to vanish after the download is completed.

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • dsvs50005 2015-03-24 10:14
    关注

    Here is something to get you started.

    HTML:

    <a id="loadPDF" href="#">Get PDF</a>
    

    JS:

    // When link is clicked show loading indicator
    $('#loadPDF').on("click", function () {
    
        // Save element
        var link = $(this);
    
        // Insert loading indicator after link
        link.after("<span> Loading...</p>");
    
        // Hide indicator after 2 seconds
        setTimeout(function(){ link.next().hide(); }, 2000);
    });
    

    You can replace the "loading..." with an animated gif. If you want to get fancier you can lookup some code that will make the loading indicator follow the mouse around. As far as removing the loading indicator after the PDF loads is a little trickier. In the example I made it disappear after 2 seconds.

    Example: JSFiddle

    评论

报告相同问题?

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端