2

我是 Swadesh,一位年轻的软件工程师,一直对 facebook 应用程序着迷。

有一次我遇到了搜索朋友、社区、应用程序等的 facebook 搜索栏。

我只是喜欢它,因为它如此之快,并为您提供智能和即时的结果。

我尝试使用 JQuery 进行类似的操作。可以在这里找到带有演示的项目

现在我面临的问题是:我将重复的记录插入到 DOM 中(从我搜索字符串的位置)。

javascript搜索思路如下

  • 在页面加载时,“将好友的所有数据从数据库加载到 DOM 中”</li>
  • 声明一个将保存 DOM 数据的数组
  • 将 DOM 数据推送到 javascript 数组中
  • 处理随后将搜索 javascipt 数组对象的 keyup 事件。如果没有找到,它将调用 ajax 函数,该函数将从数据库中收集数据。
  • 将检索到的数据再次推送到 DOM 并从那里搜索
4

2 回答 2

0

in order to handle a lot of data you should not load all the possible data to the dom while loading the page. use ajax to load the desired results and cache them in your code in order to prevent multiple calls for the same phrase. (this is also what facebook does on their search)

there are many jquery plugins out there that will make it extremely easy to integrate in your site

for example, this one: http://docs.jquery.com/Plugins/Autocomplete

于 2012-01-20T16:28:49.330 回答
0

解决了。在这最后 6 个月的时间里,我经历了不同类型的解决方案,最终找到了结果。我在此处发布的带有演示和下载链接的精确搜索功能。 http://itswadesh.wordpress.com/2011/12/23/lets-see-how-facebook-search-is-so-fast/

于 2012-05-01T08:18:09.533 回答