【发布时间】:2011-07-13 04:30:02
【问题描述】:
我想为我的文本字段做一些自动建议,使用这个插件AutoSuggest jQuery Plugin
我有一个数组,已经 json_encoded,以及服务器上的文件,js,css,但我还没有了解示例的工作原理,这里是我的代码,
<html>
<head>
<title>test-data</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="inc/css/admin_style.css" rel="stylesheet" type="text/css">
<link href="inc/css/autoSuggest.css" rel="stylesheet" type="text/css">
<script language="javascript" src="inc/js/functions.js"></script>
<script language="javascript" src="inc/js/jquery-1.5.1.js"></script>
<script language="javascript" src="inc/js/jquery.autoSuggest.js"></script>
<script language="javascript" type="text/javascript">
</script>
</head>
<body>
<center><br><font class="title">test</font></center>
<form action="dataAll.php" method="post">
Name: <input type="text" name="fname" />
<input type="submit" />
</form>
<p> </p>
<p>JSON</p>
<p> </p>
<?php
$encoded = json_encode ($familyNames);
echo $encoded;
?>
</body>
</html>
所以我应该把这段代码,
$(function(){
$("input[type=text]").autoSuggest(data);
});
- 但问题是在哪里??(好像我把它放在php标签内,它给了我一个错误
- 我应该将我的 json 格式数组的名称放在哪里? "$encoded" 让函数识别这是数据源吗?
非常感谢!
【问题讨论】:
标签: php json autosuggest