Так просто установить jQuery Autocomplete не работает для меня, почему я странный для этого, можете ли вы, пожалуйста, проверить, в чем проблема?jQuery Autocomplete с Ajax Suggestetion Not Return
Jquery Function
$("#location_suggetion").autocomplete({
autoFocus: true,
minLength: 1,
source: function(request,response) {
$.ajax ({
url: base_url+'data_check/get_location',
data: {term: request.term},
dataType: "jsonp",
cache: false,
success: function(data) {
response($.map(data.suggestions, function(item) {
return {
label: item,
value: item
}
}));
}
});
},
});
PHP File Code
$term = $this->input->get('term');
$query = $this->db->query('SELECT * FROM `tb_cities` WHERE name LIKE "'.$term.'%" LIMIT 0,6');
$results = $query->result();
$html = '';
$html.= '[';
foreach($results as $result){
$html.= '{ label: "'.$result->name.', '.get_country_row($result->country_id)->name.'", value: "'.$result->name.'" },';
}
$html.='];';
echo $html;
Console Get me Result
[{ label: "Rangat, India", value: "Rangat" },{ label: "Rajahmundry, India", value: "Rajahmundry" },{ label: "Rajamahendri, India", value: "Rajamahendri" },{ label: "Rajampet, India", value: "Rajampet" },{ label: "Rajendranagar, India", value: "Rajendranagar" },{ label: "Rajoli, India", value: "Rajoli" },];
Любые ошибки в консоли? Вызывается ли вызов ajax и возвращается со статусом 200 (OK)? –
Ошибок в консоли и правильного возврата @MoshFeu – ImBS
Ваши данные json неверны в консоли. –