简体   繁体   English

在带有w / jquery的javascript中测量大型json的下载进度

[英]measure download progress of large json in javascript w/ jquery

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. 有没有什么方法可以衡量和跟踪使用getJSON下载大型JSON文件的进度,或者如果无法做到的话,可以进行类似的测量。 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. 目前,由于getJSON基本上只有一个成功的回调,所以我不知道发生了什么,直到json完成下载为止。 (upwards of a minute) (一分钟以上)

if it helps, this will be part of a standalone chrome app and a phonegap app 如果有帮助,它将成为独立chrome应用程序和phonegap应用程序的一部分

I ended up following a guide at https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/Using_XMLHttpRequest and using XMLHTTPRequests instead of getJSON 我最终遵循了https://developer.mozilla.org/zh-CN/docs/DOM/XMLHttpRequest/Using_XMLHttpRequest上的指南,并使用XMLHTTPRequests代替了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 我还不得不在ruby上使用一些机架中间件,以便在JSON的HTTP响应中包含内容长度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM