здесь это мой код jquery:
Код: Выделить всё
$(document).ready(function() {
$(function() {
$( "#task" ).autocomplete({
source: function(request, response) {
$.ajax({
url: "digital/task_search",
data: { term: $("#task").val()},
dataType: "json",
type: "POST",
success: function(data){
response(data);
}
});
},
minLength: 1
});
});
});
Код: Выделить всё
Код: Выделить всё
public function search_task($term){
$this->db->select('work_name');
$this->db->like('work_name', $term, 'after');
$query = $this->db->get('task_name');
return $query->result();
}
Код: Выделить всё
public function task_search(){
$term = $this->input->post('work');
$rows = $this->digital_hodm_model->search_task($term);
$json_array = array();
foreach ($rows as $row)
array_push($json_array, $row->work_name);
echo json_encode($json_array);
}
Подробнее здесь: https://stackoverflow.com/questions/383 ... completion
Мобильная версия