【发布时间】:2012-06-07 16:41:27
【问题描述】:
index1.html
<html>
<head>
<link type="text/css" rel="stylesheet" media="all" href="jquery-ui-1.8.21.custom.css"/>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" src="presidents.js"></script>
<script type="text/javascript">
$(function () {
$("#presidentsServerInput").autocomplete({
source: 'getname1.php',
minLength: 2
})
});
</script>
</head>
<body>
<label for="presidentsServerInput">Select President (server-side): </label>
<input id="presidentsServerInput"/>
</body>
</html>
getname1.php
<?php
$searchTerm = $_GET['term'];
$results=array();
$conn = oci_connect("xxxxx", "yyyyy", "zzzzzzz");
$query = "SELECT first_name FROM employees where first_name like '" . $searchTerm . "%'";
$stid = oci_parse($conn, $query);
$r = oci_execute($stid);
echo oci_num_rows ($stid);
while ($row = oci_fetch_object($stid)) {
array_push($results,$row->FIRST_NAME);
}
echo json_encode($results);
?>
我可以在 FirePHP 中看到它正在正确打印数组,但我的文本框中没有收到建议。
谁能告诉我哪里出错了?
【问题讨论】:
-
是否有任何 JavaScript 错误?您确定您正确访问了 PHP 页面吗?
-
我没有看到任何 java 脚本错误。在 fireBug 上,我看到以下“NetworkError:404 Not Found - localhost/app/images/ui-bg_highlight-soft_100_eeeeee_1x100.png”并在我的 PHP 中打印了查询 - SELECT first_name FROM employees where first_name like 'St%' 和结果数组 ["Steven","Steven","Stephen "]
-
不确定你是否已经看过这个,但 jQuery UI 有 an example 和源代码。
-
我想我也是一样的,但仍然看不到我的文本框中填充的自动建议。我的 PHP 代码修改为 while ($row = oci_fetch_object($stid)) { $results [] = $row; } print($searchTerm . "\n"); echo json_encode($results);
标签: php jquery oracle-call-interface