0
这是我收到回响应(它的工作):如何访问JQuery响应jquery自动完成内部和外部的jquery自动完成?
{"matches":[
{"_core_product_id":"648","finish":"Distressed Green\/Antique Bronze","COUNT(*)":"1"},
{"_core_product_id":"157","finish":"Nightingale Green","COUNT(*)":"1"}],
"count":2}
我要显示在下拉列表中选择每个类别类别和COUNT(*)。我没有立即需要,但我可能想要在自动填充字段外的其他位置使用_core_product_id。
这里是我的自动完成的jQuery代码:
.autocomplete({
source: function(request, response) {
$.getJSON('controllers/clean/ajax/search.php', {
'fieldid_tableid_type' : this.element[0].id,
'term': extractLast(request.term)
//}, response(['red', 'green', 'blue']));
},
response);
},
search: function() {
// custom minLength
var term = extractLast(this.value);
if (term.length < 2) {
return false;
}
},
focus: function() {
// prevent value inserted on focus
return false;
},
select: function(event, ui) {
var terms = split(this.value);
// remove the current input
terms.pop();
// add the selected item
terms.push(ui.item.value);
// add placeholder to get the comma-and-space at the end
terms.push('');
this.value = terms.join('| ');
return false;
},
delay: 750
});
我想不出哪里把“回应”,以及如何使用它。任何帮助都会很棒。我知道还有其他问题(很多),但我还没有找到解决我的问题的问题。谢谢。
我注意到jquery ui文档显示刚刚在自动完成中使用的响应。而一些例子显示了其他地方(例如,在源代码中)。 jQuery UI的文档:http://api.jqueryui.com/autocomplete/#event-response
谢谢你的提示。但我不明白在哪里/如何解析json响应并将其放入下拉列表中。你能解释/显示吗?另外,我注意到你放置回应的位置与我放置的位置不同。但奇怪的是,我有另一个jQuery自动完成使用相同的确切代码(但响应json格式不同)。 – 2013-05-04 04:45:19