Php 自动完成不工作
我正在努力通过CodeIgniter实现自动完成。我跟随了一个关于这个问题的教程。 我更改了我的数据库等和变量,但当将数据库更改为一个不存在的数据库时,它不会给出任何错误,因此我猜这是视图本身的某个内容,但无法确定是什么 提前谢谢Php 自动完成不工作,php,jquery,codeigniter,autocomplete,Php,Jquery,Codeigniter,Autocomplete,我正在努力通过CodeIgniter实现自动完成。我跟随了一个关于这个问题的教程。 我更改了我的数据库等和变量,但当将数据库更改为一个不存在的数据库时,它不会给出任何错误,因此我猜这是视图本身的某个内容,但无法确定是什么 提前谢谢 <?php ?> <!DOCTYPE html> <html lang="en-US"> <head>
<?php
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<link href="<?php echo base_url() . 'resources/css/jquery-ui-1.10.3.custom.css' ?>" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="<?php echo base_url() . 'resources/js/jquery-1.9.1.js' ?>"></script>
<script type="text/javascript" src="<?php echo base_url() . 'resources/js/jquery-ui-1.10.3.custom.js' ?>"></script>
<script>
$(document).ready(function() {
alert('test');
$(function() {
$("#test").autocomplete({
source: "birds/get_birds"
});
});
});
</script>
<title>Add Project</title>
</head>
<body>
ID :<input type="text" id="test"> <br>
</body>
</html>
需要这样做:
source: "<?php echo site_url('birds/getbirds'); ?>"
来源:“
调试您的模型并查看echo json_encode
是否打印输出?当我填写错误的数据库名称(不存在)时,我认为这不是问题所在。页面没有给出任何错误。
<?php
//birds_model.php (Array of Strings)
class Birds_model extends CI_Model{
function get_bird($q){
$this->db->select('Code');
$this->db->like('Code', $q);
$query = $this->db->get('R_Projects');
if($query->num_rows > 0){
foreach ($query->result_array() as $row){
$row_set[] = htmlentities(stripslashes($row['Code'])); //build an array
}
echo json_encode($row_set); //format the array into json data
}
}
}
source: "birds/get_birds"
source: "<?php echo site_url('birds/getbirds'); ?>"