加快自动完成建议 [英] Speed up autocomplete suggestions
问题描述
我有一个脚本,该脚本使用ajax(json)来获取Google建议(xml),演示: JsFiddle
I have a script which uses ajax(json) to fetch Google suggestions(xml), demo: JsFiddle
我认为它的反应速度很慢,尤其是在第一次按键时.所以我想加快速度.我首先想到的是在keydown而不是默认的keyup上进行请求.但这并没有加快速度,并导致了另一个问题.不可能再降入列表了.所以我的问题是:是否有任何方法可以加快第一个键入(建议)的速度,也许可以将整个过程都加速?
I think it reacts to slow, especially on the first keyup. So I want to speed it up. I first thought of doing the request on keydown instead of the default keyup. But that didn't speed it up and caused another problem; it was not possible to come down in the list anymore. So my question is: Is there any way of speeding up the first keyup(suggestions), and maybe the whole thing all together?
推荐答案
我认为您应该首先加快服务器端搜索引擎的速度. +您可以在用户键入3个或4个以上字母后立即执行自动完成. (然后它将传递较少的搜索结果) +您可以在服务器端为搜索查询提供一些限制 +还要为表格分配正确的索引.
I think you should speed up your Server side search engine first. + You could do auto complete just after user typed more than 3 or 4 letters. (Then it will pass less search result) + You could give some limits for your search query in server side + Also assign right indexes for the tables.
此外,您也可以将缓存用于搜索结果.
Also you could use Cache for search result.
这篇关于加快自动完成建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!