Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 通过ASP.NET或客户端脚本了解下载何时停止_Jquery_Asp.net_Download - Fatal编程技术网

Jquery 通过ASP.NET或客户端脚本了解下载何时停止

Jquery 通过ASP.NET或客户端脚本了解下载何时停止,jquery,asp.net,download,Jquery,Asp.net,Download,我想知道是否有人会建议如何修复这个小小的视觉缺陷 在我的asp.net代码中,我生成了一个用户可以下载的文件。伪代码如下所示: Response.ContentType = "text/plain"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileName); Response.BinaryWrite(); Response.End(); .submitSpinner { margi

我想知道是否有人会建议如何修复这个小小的视觉缺陷

在我的asp.net代码中,我生成了一个用户可以下载的文件。伪代码如下所示:

Response.ContentType = "text/plain";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileName);
Response.BinaryWrite();
Response.End();
.submitSpinner
{
    margin: 0px 10px 0px 6px;
    display: none;
    width: 28px;
    height: 28px;
    display: none;
}
我还使用JQuery在服务器上生成这样的文件时,在客户端显示旋转圆的动画:

$(function () {
    $('#ButtonBeginDownload').click(function () {
        //When Submit button is clicked
        $('#IdSubmitSpinner').css('display', 'inline-block');
    });
}
微调器的CSS是这样的:

Response.ContentType = "text/plain";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileName);
Response.BinaryWrite();
Response.End();
.submitSpinner
{
    margin: 0px 10px 0px 6px;
    display: none;
    width: 28px;
    height: 28px;
    display: none;
}
和HTML:

<img id="IdSubmitSpinner" alt="" src="Graphics/spinner.gif" width="28" height="28" class="submitSpinner" />


上面的代码工作正常,当下载开始时微调器开始旋转,但不幸的是,我似乎找不到在文件下载完成时使微调器停止旋转的方法。有人知道如何解决这个问题吗?

如果您使用
Ajax
调用下载文件,您可以使用它来检测开始/停止传输:

$("#IdSubmitSpinner").bind("ajaxSend", function(){ // when user request sent
           $(this).show();
     }).bind("ajaxComplete", function(){ // when response ended
           $(this).hide();
     });

你是如何触发实际下载开始的?很久以前,但是你还记得你是否找到了解决这个问题的方法吗?我也一样problem@HansPetterNaumann当前位置我想我只是让它旋转。但是下面使用Ajax的答案可能是正确的。看看你是否能找到更好的解决方案,如果可以,就在这里发布……谢谢,不用了,我在浏览器中使用常规下载过程。如何将Ajax调用添加到其中?另外,我不想为了显示微调器而使事情变得不必要的复杂,如果你知道我的意思的话……你可以使用
jQuery
ajax()
families函数检索
plain/text
内容。例如:
$.ajax({url:'yourPageURL',type:'GET',dataType:'text',success:function(retrievedContent){//对检索到的内容做任何想做的事。})