lundi 23 avril 2018

Event to indicate download started and/or finished

I'm using anchor to download a file, and I would like to handle the start and end event. I tried this... JS:

function downloadReport(){
    $('#eventmessage').css('display','block');
    var $a = $("<a>");
    $a.attr("href","../dataObject/reporte/get_report.php);
    $("body").append($a);
    $a.attr("download");
    $a[0].click();
    $a.remove();
    $('#eventmessage').css('display','none');
}

HTML:

<div id='btn_ttab1' class='btn-table bt-act' style="cursor: context-menu;" onclick="downloadReport">
Download EXCEL
</div>
<span id="eventmessage" style="display:none">Loading...</span> 

The downloaded file is an Excel file of 40,000 rows, created using Spout (PHP Free Library) and can last more than 25 seconds. That's why I want to get the start and end event so I can show a "Loading" message using something like a span.




Aucun commentaire:

Enregistrer un commentaire