jQuery Autocomplete Remote


jQuery Autocomplete Remote

我在我的网站上使用此 http://jqueryui.com/demos/autocomplete/#multiple-remote,我可以看到此代码"搜索"搜索.php有谁知道搜索.php应该采用什么格式以及它应该是什么样子?

谢谢

在您链接的页面中,它显示了预期的数据格式。(粘贴在下面)最简单的是,您可以在 search.php 文件中有一个 print 语句,该语句只是回显一些硬编码的内容。更复杂的解决方案是进行搜索.php从数据库中提取实时数据,然后按预期格式化数据。

Expected data format
The data from local data, a url or a callback can come in two variants:
An Array of Strings:
[ "Choice1", "Choice2" ]
An Array of Objects with label and value properties:
[ { label: "Choice1", value: "value1" }, ... ]

因此,只是为了起步并看到它的工作原理,请使用此行进行搜索.php并通过自定义您的选择或连接到数据库等从那里进行构建。

print '[ "Choice1", "Choice2" ]';