【发布时间】:2015-10-27 07:12:38
【问题描述】:
我正在尝试使用 jquery 创建文本框自动完成功能。但是当我在调试器中检查它时出现了问题,它显示了每个值,但它没有显示在视图页面的文本框下拉列表中。我是新手,所有帮助将不胜感激。
这是我的视图代码。
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript">
$(function(){
$("#location").autocomplete({
source: 'set_location'
});
});
</script>
<form action= "#">
<table>
<tr>
<td><label for='location'>Location</label></td>
<td><input id="location" type="text" size="50" placeholder="Enter a location" name= "location"> </td>
</tr>
</table>
</form>
这是我的控制器代码
if(isset($_GET['term'])){
$location = strtolower($_GET['term']);
$query = $this->venues_model->set_location($location);
echo $query;
}
这是我的型号代码
$this->db->select('*');
$this->db->like('location', $location);
$query = $this->db->get('venue_details');
if(count($query->result_array()) > 0){
foreach ($query->result_array() as $row){
$row_set[] = htmlentities(stripslashes($row['location']));
}
echo json_encode($row_set);
}
【问题讨论】:
-
控制台有错误吗??
-
不,它什么也没显示。
标签: php jquery sql codeigniter