我想在自動完成腳本添加圖片。 這是我的代碼,請幫助解決它。如何將圖像實現爲自動完成腳本?
這裏我Countroller是
function getsearch($c_id)
{
$searchTerm = $_GET['term'];
$query = $this->db->query("SELECT state_name FROM state WHERE country_id = '".$c_id."' and state_name LIKE '".$searchTerm."%'");
foreach ($query->result_array() as $row)
{
$data[] = $row['state_name'];
}
echo json_encode($data);
}
我查看如下
<input type="text" placeholder="Enter Location (E.g. Ontario)" class="sarbx ani-1" name="location" id="compnies_id">
Java腳本
function state_search()
{
$(function() {
var country = $('#countries').val();
var controller = 'directories/getsearch';
var url = '<? echo base_url();?>';
$("#compnies_id").autocomplete({
source: url+''+controller+'/'+country
});
});
}
在此先感謝。 :)
你能顯示來自一個示例響應添加這些clases控制器用作源? – Viney