好吧,我一直在绞尽脑汁(我在这方面很糟糕),但是的,我试着尽我所能阅读,但仍然无法让它发挥作用.
try 使用jQuery UI执行自动完成
my json looks like this
{"dealers":
{
"1156":"dealer 1",
"1122":"dealer 2",
"1176":"dealer 3",
"1491":"dealer 4",
"1463":"dealer 5",
"269":"dealer 6"
}
}
我正在try 使用此信息作为自动完成的来源.我可以很好地获取响应对象,只是格式不正确,这样我就可以将"#"放在与"value"绑定的隐藏字段中,而"value"需要显示为下拉列表的一部分.
been trying a million different ways but a recent attempt was below
function ajaxCall() {
$.getJSON("/example/location/example.json?term=" + $('#dealerName').val(),
function(data) {
$.each(data.dealers, function(k, v) {
alert(k + ' : ' + v);
});
});
}
$('#dealerName').autocomplete({
source: ajaxCall,
minLength: 2,
delay: 100
});
Please and thank you much!