JQuery的自动完成服务器端的匹配 [英] JQuery autocomplete server-side matching
问题描述
我想设置自动完成场。
我心中已经阅读JQuery用户界面的文件,但所有的示例中,假设源是项目从jQuery将挑选匹配的条目(我的意思是静态的静态列表=列表是完整的,不依赖于用户是什么键入)。
I'v read the JQuery UI documentation, but all the example assume the source is a static list of items from which JQuery will pick matching entries (I mean static = the list is complete and doesn't depend on what the user typed).
下面是从远程数据源例如code:
Here is the code from the "remote datasource" example:
$( "#birds" ).autocomplete({
source: "search.php",
...
我想jQuery来调用的search.php?查询= MYTEXT
(此URL返回匹配项目的列表),因为我需要查找数据库中使用PHP建议
I would like JQuery to call search.php?query=mytext
(this URL returning a list of matching items) because I need to lookup suggestions in a database using PHP.
有没有办法做到这一点?也许我不明白的文档?
Is there a way to do that? Maybe I didn't understand the documentation?
推荐答案
从自动完成的jQuery UI的文档:
from the jQuery UI Documentation on autocomplete:
自动完成可定制各种数据源的工作,仅通过指定源选项。数据源可以是:
Autocomplete can be customized to work with various data sources, by just specifying the source option. A data source can be:
- 本地数据的阵列
- 一个String,指定网址
- 回调
和进一步回落
当使用字符串,则自动完成插件预计字符串以指向URL资源,将返回JSON数据。它可以是相同的主机上或在一个不同的(必须提供JSONP)。请求参数项被添加到该URL。如上所述的本地数据中的数据本身可以是相同的格式。
When a String is used, the Autocomplete plugin expects that string to point to a URL resource that will return JSON data. It can be on the same host or on a different one (must provide JSONP). The request parameter "term" gets added to that URL. The data itself can be in the same format as the local data described above.
你试过了code你放弃?它应该调用网址的search.php?长期= MYTEXT
have you tried the code you give? it should call the url search.php?term=mytext
这篇关于JQuery的自动完成服务器端的匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!