简体   繁体   English

如何加快getJSON数组数据

[英]how to speed up getJSON array data

I have a huge array(4MB) data on the server side. 我在服务器端有一个巨大的数组(4MB)数据。 right now I'm using jquery getJSON method to get the array data and render the whole array on the browser. 现在,我正在使用jquery getJSON方法获取数组数据并在浏览器上呈现整个数组。 It turns out getting the array data is too slow. 事实证明,获取数组数据太慢。 Probably the main time is spent on JSON parsing,probably not. 可能主要时间花费在JSON解析上,也许没有。 What is the best/fastest way to get such array kind of data from server? 从服务器获取此类数组类型数据的最佳/最快方法是什么?

Four MegaBytes is a lot of data to be sending client side in all one go? 一口气发送四个兆字节是很多数据吗? Rather than trying to speed up how fast JavaScript can process JSON, i suspect your best bet will be to figure out some tactics to break the data up a bit more (so you can work with less at a time). 我怀疑您最好的选择不是找出加快JavaScript处理JSON的速度的方法,而是想出一些策略来使数据分解得更多一些(以便您一次处理更少的数据)。

I mean, do you really need all of it at once? 我的意思是,您真的真的需要所有这些吗? Its probably worth looking in to adding some server side filtering to the JSON being returned so as to try and limit it only to the data needed to do whatever you apps supposed to be doing? 可能值得考虑在返回的JSON上添加一些服务器端过滤,以便尝试将其限制为仅执行应用程序应做的事情所需的数据?

For example, if your planning to display a massive list of products, it may be worth just loading the first 50-100, then as the user scrolls down the page make a second call to load the next 50-100 etc? 例如,如果您打算显示大量产品,那么仅加载前50-100个产品就值得,然后当用户向下滚动页面时再次拨打电话以加载下一个50-100个产品吗?

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

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