0
$(function() {
$("#restaurant_name_search").autocomplete({
source: function(d, e) {
$.ajax({
type: 'GET',
url: api_url + 'searchrestuarant/' + encodeURIComponent(d.term),
success: function(b) {
var c = [];
b = JSON.parse(b);
$.each(b, function(i) {
i.label = i.Restaurant_Name;
c.push(i);
});
e(c);
}
})
},
select: function(a, b) {
console.log(b);.
}
}).data("ui-autocomplete")._renderItem = function(ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.label + "</a>") // <---
.appendTo(ul);
};
});
這是我的jquery ui調用。jquery ui自動完成undefined
JSON的輸出如下:
[{
"Restaurant_Key": "1",
"Restaurant_Name": "Altitude Espresso",
"Email": "",
"Phone_1": "",
"Local_Restaurant_Key": "1",
"Address_Line1": "163 Oriordian Street",
"City": "Mascot"
}]
但總是自動完成顯示未定義。
輸出從url接收。
商品中沒有標籤 – guradio