动态过滤,我做错了吗?
因此,我有一个 umbraco 网站,其中包含许多内容管理的产品,我需要根据 5 个条件在前端搜索/过滤此数据集。
我估计我会有 300 种产品。我需要非常快速地过滤这些数据,并根据之前的选择隐藏不再相关的显示选项。
我目前正在使用 AJAX 构建 Web 服务和 jquery 实现。
最好的方法是将其加载到 JavaScript 数据结构中并在那里对其进行操作,还是 AJAX 调用足够快?显然,这意味着为非 JavaScript 用户复制服务器端的功能。
So I have an umbraco site with a number of products in it that is content managed, I need to search/filter this dataset on the front end based on 5 criteria.
I'd estimate I will have 300 products. I need to filter this data very fast and hide show options that are no longer relevant based on the previous selections.
I'm currently building a webservice and jquery implementation using AJAX.
Is the best way to do this to load it into a javascript data structure and operate on it there or will AJAX calls be fast enough? Obviously this will mean duplicating the functionality on the server side for non-javascript users.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您需要“非常快”地过滤数据,那么我想最好的方法是预加载所有数据,然后在客户端进行操作。如果每次用户需要过滤数据时您都在等待 Ajax 响应,那么它不会像在客户端上过滤数据那么快(假设他们没有运行 IE6 的古老计算机)。
这取决于过滤的复杂性。如果您所做的只是显示结果,例如产品的价格大于 10 美元,那么速度肯定会快得多。如果您要进行复杂的搜索,那么在服务器端处理可能会更快。另一个问题是为每个产品保存多少数据 - 预加载数百个具有大量数据的产品可能需要一些时间。
与往常一样,真正能够回答这个问题的唯一方法是分析这两个解决方案。
If you need to filter the data "very fast" then I imagine the best way is to preload all the data then manipulate it client side. If you're waiting for an Ajax response every time the user needs to filter the data then it's not going to be as fast as filtering it on the client (assuming they haven't got an ancient computer running IE6).
It would depend on the complexity of your filtering. If all your doing is showing results where, for example, the product's price is greater than $10, then that will definitely be much faster. If you're going to be doing complex searches then it's possible that it could be faster to process serverside. The other question is how much data is saved for each product - preloading a few hundred products with a lot of data may take some time.
As always, the only way you'll truly be able to answer this question is by profiling the two solutions.