$.ajax({
type: "POST",
url: "AutoComplateHandler.ashx",
success: function (data, status) {
if (status == "success") {
var source = [
{ "Name": "Java", "Age": 22 },
{ "Name": "C++", "Age": 232 },
{ "Name": "PHP", "Age": 233 },
{ "Name": "Python", "Age": 231 },
{ "Name": "Perl", "Age": 230 },
{ "Name": "Asp", "Age": 213 },
{ "Name": "C++", "Age": 23 }
];
$("#txtComplate").autocomplete({
source: source, //["Java","C++","PHP","Python"]
//如何提取json Name集合
select: function (event, ui) {
alert(ui.item.value);//获取当期选择的value 如何根据当期选中Name
//属性(如:Java)的值获取相对应的Age值
}
});
}
}
});
------解决方案--------------------
an array of objects with label and value properties: [ { label: "Choice1", value: "value1" }, ... ]
键值名称改成label和value,不支持你那种格式的数据,要不你就需要手动转换了
var source = [
{ "Name": "Java", "Age": 22 },
{ "Name": "C++", "Age": 232 },
{ "Name": "PHP", "Age": 233 },