My problem is very similar to this one: Downloading large files with jQuery & iFrame - Need a File Ready event so I can hide the loading gif I need to download an excel report and while it is generating I want to show some gif that generating is in progress. After report is downloaded I want to hide this gif animation. That's what I wrote:
//...
} else if(dest == "xls") {
Main.pm.showLoadingMessage(); //Show progress gif
var iframeId = "currentReportIframe";
$("#" + iframeId).remove();
var iframe = $("<iframe/>").attr({
id: iframeId,
src: "./services/ReportsResource/getCurrentViewReport?" + common,
style: "visibility:hidden;display:none"
});
iframe.load(function() {
Main.pm.hideLoadingMessage(); //Hide progress gif
});
$('body').append(iframe);
return false;
}
//...
Unfortunately this solution doesn't work in Google Chrome(at least v. 44), but works fine in Firefox.
I also tried solution from the question above. However, it hides my progress bar immediately, so I even don't see it on the screen.
Any ideas how I can solve my problem?
UPD:
@a-wolff, Thank you for your comments. When I put onload
callback before set src
browser even doesn't send a request. That's what I tried:
Main.pm.showLoadingMessage();
var iframeId = "currentReportIframe";
$("#" + iframeId).remove();
var iframe = $("<iframe/>").attr({
id: iframeId,
style: "display:none"
});
$("#" + iframeId).load(function() {
Main.pm.hideLoadingMessage();
});
$("#" + iframeId).attr('src', './services/ReportsResource/getCurrentViewReport?' + common);
$('body').append(iframe);
@epoch In my case callback function fires once, but probably it doesn't fires the second time because of some kind of WARNING message which I receive in Chrome Console:
Resource interpreted as Document but transferred with MIME type application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Since I download an excel spreadsheet(*.xlsx) I set a appropriate MIME type on server side.