【发布时间】:2015-09-28 10:53:51
【问题描述】:
我正在尝试为我正在为我的公司构建的网站设置自动完成功能,但我似乎无法执行 jQuery 函数。该网站建立在 Wordpress 之上。
输入行:
<strong>Customer: </strong> <input type='text' name='cust' id='cust'>
自动完成:
<script type='text/javascript'>
jQuery('#cust').autocomplete({
source : "Scripts/cust_search.php",
minLength:1
});
还有 cust_search.php:
<?
$term = trim(strip_tags($_GET[ "term" ]));
$a_json = array ();
$a_json_row = array ();
if ($companies = $panther->get_results("SELECT Cust_ID, Cust_Name FROM Customer LIKE '%$term%' ORDER BY Cust_Name ASC;")) {
while ($row = mysqli_fetch_array($companies)) {
$a_json_row ["id"]=$panther->escape($row['Cust_ID']);
$a_json_row ["value"]=$panther->escape($row['Cust_Name']);
$a_json_row ["label"]=$panther->escape($row['Cust_Name']);
array_push($a_json, $a_json_row);
}
}
echo json_encode( $a_json );
?>
【问题讨论】:
-
你看过浏览器控制台中的请求/响应吗?
标签: php jquery wordpress autocomplete