I have a page on a website where you can download files that you previously paid for. The file is a zip archive that contains many pdf files. When the download link is clicked, a php file is called that does some work (adding stamp on the pdf's) before the file is served. Because this can take some time on larger files, I'v build in a polling mechanism to show the user what is happening. The polling is done through an ajax call that looks like this:
$('.rm-table').on(clickhandler,'.fa-download', function(e){
tr = $(this).closest('tr');
id = tr.attr('id');
tr.find("progress").show();
tr.find('.downloadstatus').show();
tr.find('.downloadstatus').html('Start Download...');
setTimeout(getDownloadStatus(), 250);
});
function getDownloadStatus(){
setTimeout( function() {
$.ajax({
url: '/process/{{Auth::id()}}/'+id,
type: 'POST',
async: true,
cache: false,
data: {},
dataType: "json",
success: function(data, textStatus, jqXHR)
{
var tekst = data.tekst;
var perc = data.percentage;
tr.find('.downloadstatus').html(tekst);
tr.find('progress').val(perc);
if(tekst != 'done'){
getDownloadStatus();
} else {
tr.find('.downloadstatus').html("Done!");
tr.find('progress').val(100);
setTimeout(
function()
{
tr.find('progress').val(0);
tr.find('progress').hide();
tr.find('.downloadstatus').html("");
tr.find('.downloadstatus').hide();
}, 750);
}
},
error: function(jqXHR, textStatus, errorThrown) {
var response = jQuery.parseJSON(jqXHR.responseText);
alert(response.error);
}
});
}, 250);
}
The polling is done after the user clicks the link. So the default behaviour of the link is not prevented.
This works fine on all browsers on Windows, but the polling is somehow not started on Safari on a mac, or even other browsers on an ipad. Anyone any idea of what may be the problem?