AJAX 页面下载进度 [英] AJAX Page Download progress

查看:29
本文介绍了AJAX 页面下载进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解我的 AJAX 请求的进度 - 到目前为止已经下载了多少文件.例如,我正在使用 AJAX 下载一张大图片,因此我可以将内容放在 DATA url 中(这可能不是最好的方法,这只是一个示例.)

I want to get the progress of my AJAX request - how much has been downloaded so far out of how much the file is. For example, I am downloading a large picture with AJAX so I can put the content in a DATA url (this may not be the best way to do that, it's just a example.)

因此,我向某个我无法控制的主机 (flickr) 发出 AJAX 请求,并将进度报告给用户.如果没有服务器端脚本或类似的东西,我无法找到一种方法来做到这一点.最好的解决方案是使用 JQuery,因为这是我在我的网站上使用的.谢谢!以撒

So, I make the AJAX request to some host I have no control over (flickr), and report the progress back to the user. I cannot find a way to do this without a server-side script or something like that. Preferably the solution would use JQuery, because that is what I use for my website. Thanks! Isaac

推荐答案

据我所知,$.ajax() 函数不支持加载字节数".它只有开始和完成事件,没有进度事件.

As far as I know, the $.ajax() function has no support for "bytes loaded". It only has start and complete events, no progress event.

我发现 这个线程 详细说明了一次尝试,但显然该代码适用于多种浏览器,但不适用于 IE.他们提出的建议是在其他浏览器中显示进度,并为 IE 显示一条简单的正在加载..."消息.

I found this thread detailing an attempt, but apparently the code works in several browsers but not IE. The suggestion they make is to show progress in other browsers, and a simple "loading..." message for IE.

请注意,同一站点上有多个类似的讨论,因此请浏览左侧面板以了解其他方法.

Do note that there are several similar discussions on the same site, so browse the left panel for other methods.

这篇关于AJAX 页面下载进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆