测量大型json在javascript w / jquery中的下载进度 [英] measure download progress of large json in javascript w/ jquery

查看:99
本文介绍了测量大型json在javascript w / jquery中的下载进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么方法可以衡量并跟踪使用getJSON下载大型JSON文件的进度,或者如果无法做到这一点类似的话。
,因为getJSON基本上只有成功的回调函数,所以直到json完成下载后我才知道发生了什么。 (一分钟以上)

如果有帮助,这将成为独立Chrome应用程序和phonegap应用程序的一部分

解决方案

我最终在
https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/Using_XMLHttpRequest
并使用XMLHTTPRequests代替getJSON



我还不得不在rails侧的ruby上使用一些机架中间件,以在JSON的HTTP响应中包含内容长度

Is there any way to measure and keep track of the progress of downloading a large JSON file using getJSON, or something similar if that can't do it. at the moment, since getJSON has basically only a success callback, i don't know what's going on until the json is done downloading. (upwards of a minute)

if it helps, this will be part of a standalone chrome app and a phonegap app

解决方案

I ended up following a guide at https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/Using_XMLHttpRequest and using XMLHTTPRequests instead of getJSON

I also had to use some rack middleware on the ruby on rails side to include content-length in the HTTP response for JSON

这篇关于测量大型json在javascript w / jquery中的下载进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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