我正在尝试设置自动填充字段.
我读了JQuery UI文档,但是所有的例子都假设源是一个静态的项目列表,JQuery将从中选择匹配的条目(我的意思是静态=列表是完整的,不依赖于用户键入的内容).
以下是“远程数据源”示例中的代码:
$( "#birds" ).autocomplete({
source: "search.PHP",...
我希望JQuery调用search.PHP?query = mytext(此URL返回匹配项列表)因为我需要使用PHP在数据库中查找建议.
有没有办法做到这一点?也许我不懂文档?
最佳答案
来自自动完成的jQuery UI文档:
原文链接:https://www.f2er.com/jquery/428429.htmlAutocomplete can be customized to work with varIoUs data sources,by just specifying the source option. A data source can be:
- an Array with local data
- a String,specifying a URL
- a Callback
并进一步下来
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.