阿贾克斯文件下载问题斯文、问题、阿贾克

由网友(查理的天使)分享简介:我下载我的应用程序动态的文件,使用内置页框模拟阿贾克斯。我在做什么,当下载请求时,我将创建一个动态的无形的iframe,并设置我的iframe的下载url.I我能够成功下载该文件的src,但要求是要显示一个下载指标一旦下载开始,且应尽快完成在下载对话框出现up.I提供的电话后回iframe的创作显示下载的指标,这是成功...

我下载我的应用程序动态的文件,使用内置页框模拟阿贾克斯。我在做什么,当下载请求时,我将创建一个动态的无形的iframe,并设置我的iframe的下载url.I我能够成功下载该文件的src,但要求是要显示一个下载指标一旦下载开始,且应尽快完成在下载对话框出现up.I提供的电话后回iframe的创作显示下载的指标,这是成功的工作,并在iframe的'onload事件提供了另一种方法,希望它会被调用,当下载对话框出现。但不幸的是,这是行不通的,正因为如此下载完成,即使,我的进步指标依然存在。我不能够删除。后来我才意识到,由于响应的内容类型不是HTML,它会通过一个单独的进程,从而导致下载对话框送达,正因为如此我的onload方法永远不会获取调用。请让我知道了一个解决方案。

I am downloading a dynamic file in my application, simulating ajax using iframes. What I am doing is, when the download request is made, I will create a dynamic invisible iframe, and set the src of my iframe as the download url.I am able to successfully download the file, but the requirement is to show a download indicator once the download starts and that should finish as soon as the download dialog comes up.I provided call back after iframe creation to show the download indicator, which is successfully working, and provided another method on the 'onload' of the iframe, expecting it will be invoked, when the download dialog comes up. But unfortunately, that is not working, and because of that even after the download completes, my progress indicator is still there. I am not able to remove that. Then I came to realize that the since the content type of the response is not html, it will be served by a separate process, which leads to the download dialog and because of that my onload method is never getting called. Please let me know a solution for this.

推荐答案

您应该开始在客户端的计时器,当下载请求是由该测试在指定的时间间隔iframe的状态:

You should start a timer in the client when the download request is made which tests the state of the iframe at a specified interval:

if ( ( iframe.document && iframe.document.readyState == 'complete' )
    || iframe.contentDocument )
{
    stopTimer();
    closePopupDialog();
}
阅读全文

相关推荐

最新文章