自动建议技术和选项

时间:2010-02-25 05:45:31

标签: javascript jquery ajax autosuggest

我想在我的网站上集成自动推荐功能。我应该选择哪个选项?使用jQuery路由与Javascript路由有什么好处吗?缺点怎么样?

从服务器端JSP获取本地javascript请求信息怎么样?我的数据库中有大约10,000个关键字,我将使用它。

我很欣赏这方面的一些方向。谢谢。

4 个答案:

答案 0 :(得分:3)

这不是jQuery vs Javascript。 jQuery只是巧妙编写的javascript,旨在让您的生活更轻松,而且它就是这样。实际上,您无需从头开始创建自动建议元素,而是可以下载使用/为jQuery构建的autosuggest plugins

至于处理10,000个项目,我想我会在用户输入以获取特定项目时触发异步请求。如果用户输入“app”,您可以找到以“app”开头的所有关键字,并将其作为autosuggest框的人群返回。这将大大减少带宽和加载时间。

答案 1 :(得分:0)

你可以用任何编程语言来做。您可以研究OpenSearch规范和格式,以便提供来自第三方的通用和可重用的内容。

答案 2 :(得分:0)

在我看来,JQuery是一个很好的选择。我亲自使用http://docs.jquery.com/Plugins/Autocomplete,这个插件非常有前途。

就10,000个项目而言,您可以在DB中的特定列上使用索引来加速搜索过程。

答案 3 :(得分:0)

我会采取以下步骤

create a dictionary in the client using json or something
1. wait for inputs > 4 characters in the text box 
2. send the request to server using ajax
3. use like search in your sql query.
4. send back the data to the client
5. pass the data to the text box div overlay so that it highlights.
6. add the same data set to the dictionary. this will help for later searches.