Reputation: 2986
I have some code like this.
function ExportToExcel() {
showLoading();
window.location.href = "/UI/WorkingTime/CreateFile.aspx?Type=1";
// I want hide loading here
//window.hideLoading();
};
How can I hide loading after create file completed? How can I detect that created file completed?
Upvotes: 0
Views: 125
Reputation: 1075239
This line:
window.location.href = "/UI/WorkingTime/CreateFile.aspx?Type=1";
will completely tear down the page and the JavaScript environment associated with it, and replace it with a new page and associated JavaScript environment containing the response from the server. So you can't do window.hideLoading();
as that function, and the environment it was in, have been discarded to make room for the new environment of the new page.
If you don't need the response from that URL displayed in the current page, you can retrieve it via ajax (fetch
, XMLHttpRequest
), or use an iframe
instead, and then you could use code in the page being loaded to tell its parent window that it was loaded, so that the parent window could hide the loading indicator.
Upvotes: 1