【发布时间】:2015-04-14 15:14:29
【问题描述】:
我在 ajax 调用中创建一个国家列表,它是一个对象数组:
$.ajax({
url: '//maps.googleapis.com/maps/api/geocode/json?address=' + zipCode + '®ion=AT',
type: 'GET',
dataType: 'json',
success: function (res){
var countryList = [];
... ...
... ...
countryList.push({
label: countryCode + ' ' + countryName,
value: result[0]['id'],
countryId: result[0]['id'],
countryCode: countryCode,
countryName: countryName,
city: city
});
zipCodeSelector.autocomplete({
source: countryList
});
}
})
自动完成的响应是
没有搜索结果
对象看起来像这样:
[Object]
0: Object
city: "Berlin"
countryCode: "DE"
countryId: "a7c40f631fc920687.20179984"
countryName: "Germany"
label: "DE Germany"
value: "a7c40f631fc920687.20179984"
我在 ajax 中调用自动完成功能。这是问题还是有其他问题?
【问题讨论】:
-
我不确定这是否是拼写错误,但您在 ajax 网址末尾缺少
'。 -
您应该将自动完成调用移动到 ajax 调用的
success()函数内。 -
是的,就像是复制粘贴问题...我编辑了我的问题
标签: javascript jquery ajax jquery-ui jquery-autocomplete