jQuery自动完成远程

时间:2012-06-09 17:51:13

标签: php jquery json jquery-ui

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

谢谢,

1 个答案:

答案 0 :(得分:0)

从您链接的页面,它会显示预期的数据格式。 (粘贴在下面)最简单的是,你可以在search.php文件中有一个print语句,它只是回显一些硬编码的内容。更精细的解决方案是让您的search.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" }, ... ]

所以,只是为了起步并看到它正常工作,请将此行用于search.php并通过自定义您的选择或连接到数据库等来构建。

print '[ "Choice1", "Choice2" ]';
相关问题