Php Jquery UI自动完成有问题
我的php代码是这样的Php Jquery UI自动完成有问题,php,jquery,mysql,jquery-ui,mysqli,Php,Jquery,Mysql,Jquery Ui,Mysqli,我的php代码是这样的 if (isset($_REQUEST['term'])) { $term = trim(strip_tags($_REQUEST['term']));//retrieve the search term that autocomplete sends $result = $db->query("SELECT company as value,id FROM main WHERE company LIKE '$term'") or die(mysq
if (isset($_REQUEST['term']))
{
$term = trim(strip_tags($_REQUEST['term']));//retrieve the search term that autocomplete sends
$result = $db->query("SELECT company as value,id FROM main WHERE company LIKE '$term'") or die(mysqli_error());;
$results = array();
while ($row = $result->fetch_row()) $results[] = array( 'id' => $row[0] , 'label' => $row[1], 'value' => $row[1] );
echo json_encode($results);
}
下面是Js代码
$("#auto").autocomplete({
source: "index.php",
minLength: 2,//search after two characters
select: function(event,ui){
}
});
和HTML标记
<input id="auto" name="company"/>
代码怎么了?它不会生成自动完成选项。。php日志文件中没有错误。如何解决这个问题?假设json正常,那么您就不会对返回的数据进行任何处理
select: function(event,ui){
// do something with the data you get back
//you would usually have a function here to do something with data
// but this sample should be enough for you
var id = ui.id; // id you got back assign to var
var label = ui.label; // label you got back assign to var
$('#gothisback').val(ui.id); //push it to a div
}
哪个部门?我想把它作为自动完成菜单拿回来