オートコンプリート jQuery メソッドとして値をフェッチし、選択した入力値をテキスト ボックスに格納しようとしています (テキスト ボックスにプッシュ)。簡単に聞こえるかもしれませんが、この JSON スキーマにはかなりの時間がかかります。
ここですぐに助けてもらえますか?
jQuery コード:
$("#material_number").autocomplete({
source: function (request, response) {
$.ajax({
url: "http://ws.geonames.org/searchJSON",
dataType: "json",
data: {
style: "full",
maxRows: 12,
name_startsWith: request.term
},
success: function (data) {
response($.map(data.geonames, function (item) {
return {
// following property gets displayed in drop down
label: item.name + ", " + item.countryName,
// following property gets entered in the textbox
value: item.name,
// following property is added for our own use
my_description: item.fcodeName
}
}));
}
});