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