当前位置: 代码迷 >> JavaScript >> 在ASP.NET中,使用Response.end下载excel,并提供客户端javascript加载器。 我无法显示但无法隐藏
  详细解决方案

在ASP.NET中,使用Response.end下载excel,并提供客户端javascript加载器。 我无法显示但无法隐藏

热度:49   发布时间:2023-06-08 09:36:42.0

response.end()客户端脚本将永远无法运行。 使用Response.writeResponse.end时,是否还有其他方法可以显示隐藏加载程序?

一种常见的方法是在调用Response.End()之前在服务器上设置cookie。

HttpCookie fileDownloadToken = new HttpCookie("fileDownloadToken", "1");

然后创建一个间隔以检查该cookie是否存在

 function btnSubmit_Click() {

    // Show loader
    // Submit to server

    fileDownloadCheckTimer = window.setInterval(function () {
        if ($.cookie('fileDownloadToken') == '1') {
            window.clearInterval(fileDownloadCheckTimer);
            $.removeCookie('fileDownloadToken', { path: '/' });

            // Hide loading panel here
        }
     }, 1250);
}
  相关解决方案