JQuery發送請求,我看到沒有錯誤的響應(通過Firebug)。但對於一個或兩個字符,結果不會顯示在下拉列表中。通常在第二個字符輸入結果開始顯示(我慢慢打字,每秒1個字符左右,只是爲了測試它是否是某種速度問題)。JQuery UI Autosuggest不立即顯示項目
這裏是螢火蟲的請求/ RESP的例子,在這一點上的項目不被顯示在頁面上:
{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"fl":"title,count",
"sort":"count desc",
"indent":"on",
"start":"0",
"q":"\"b\" AND count:[3 TO *]",
"wt":"json",
"rows":"5",
"version":"2.2"}},
"response":{"numFound":6536,"start":0,"docs":[
{
"title":"blood",
"count":19890},
{
"title":"biochemistry",
"count":14480},
{
"title":"biochemical and biophysical research communications",
"count":6976},
{
"title":"businessweek",
"count":6498},
{
"title":"biochimica et biophysica acta",
"count":6226}]
}}
同樣,正如我所說,控制檯顯示頁面上沒有錯誤。
有關我該如何解決這個問題的想法?
的JavaScript代碼是:
function autosuggest(term, wid)
{
var query = "q=" + escape(term);
var url = "/autosuggest.do?" + query;
$.getJSON(url, function(terms)
{
// iterate over terms
var list = new Array();
if (terms.response != null && terms.response.docs != null) {
for(var i=0; i < terms.response.docs.length; i++)
{
var trm = terms.response.docs[i];
list[i] = trm.title;
}
$('#' + wid).autocomplete({source: list, select: function(event, ui) {
doSuggestedSearch(ui.item.value);
}});
}
});
}
任何想法,將不勝感激。
當您查看Firebug(或其他開發控制檯)中的數據時,數據是否與您對每個請求所期望的一樣? –