0

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 中看到它正在正确打印数组,但我的文本框中没有收到建议。

有人能告诉我我在哪里犯错吗?

4

1 回答 1

0

从 jQuery http://jqueryui.com/demos/autocomplete/#remote-jsonp的示例中查看 jQuery UI 自动完成的打开选择和关闭方法

于 2012-06-07T16:48:28.527 回答