jQueryオートコンプリートを設定するのは簡単ではありませんなぜ私はこれに奇妙なのですか?jQueryオートコンプリートwith Ajax Suggetionが返されない
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" },];
Json
か? ajaxコールが送信され、ステータス200(OK)で返されますか? –コンソールにエラーがなく、正常に戻る@MoshFeu – ImBS
jsonデータがコンソールで間違っています。 –