简体   繁体   English

使用多个ajax请求处理“大数据json请求”

[英]Handling “large data json requests” with multiple ajax requests

What is the best way to handle large data PHP Array past though multiple ajax requests. 通过多个ajax请求处理大型数据PHP Array的最佳方法是什么?

For example. 例如。 I have a php array which contains 10,000 product id's which is the result of the first ajax request Once on the second ajax request, I have to first query again to get the 10,000 product id's then in addition the 2nd request may fetch a further 3000 product id's 我有一个包含10,000个产品ID的php数组,这是第一个ajax请求的结果。在第二个ajax请求中,我必须先再次查询以获取10,000个产品ID,然后另外,第二个请求可能会获取另外3000个产品id的

So the process is: in each request we need to modify the product ids append/remove. 因此,过程是:在每个请求中,我们都需要修改产品ID追加/删除。

The method I am currently looking into is storing the id's via session or cookie. 我目前正在研究的方法是通过会话或cookie存储ID。 But the best solution would be to serialize the array then past through jsonEncode 但是最好的解决方案是序列化数组,然后通过jsonEncode

The problem is this must be to much data to be pass through each request. 问题在于这必须要使大量数据通过每个请求。 I have currently tried setting a global at the top of our script. 我目前尝试在脚本顶部设置一个全局变量。

var globalProductIds = 0 var globalProductIds = 0

then on success of each request we would override the product id's and send with the next request. 然后在每个请求成功后,我们将覆盖产品ID并发送下一个请求。 globalProductIds = data.productIds; globalProductIds = data.productIds;

Currently this freezes the browser. 当前,这将冻结浏览器。 The only other method which I can think of if json is not going to work, would be to store the id's in the database, this is not particularly a good solution as there could be 1000's of rows generated for each user per minute. 如果json无法正常工作,我可以想到的唯一其他方法是将id存储在数据库中,这并不是一个很好的解决方案,因为每分钟每位用户可能会产生1000行。

Hopefully someone out there has a better suggestion. 希望外面有人有更好的建议。

Ok it seems I have got no response in the past 24hrs. 好的,在过去24小时内似乎没有任何反应。 After further research it seems javascript is not the best method for processing large amounts of data. 经过进一步研究,似乎javascript不是处理大量数据的最佳方法。

I have now started to build a caching system which uses the database. 我现在开始构建一个使用数据库的缓存系统。 This certainly seems to be the best solution now. 这无疑是目前最好的解决方案。

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

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