-1
你好,我正在嘗試解析搜索框中的solr建議器查詢輸出,但沒有得到確切的結果。 plz幫助...........如何在ajax自動完成中解析solr建議器組件json響應?
$(document).ready(function() {
$("#searchterm").autocomplete({
source: function(request, response) {
var text = $("#searchterm").val();
$.ajax({
url: 'http://localhost:8983/solr/collection1/suggest?wt=json&indent=true&spellcheck=true&spellcheck.q='+request.term+'&spellcheck.onlyMorePopular=true&spellcheck.count=50&start=0&rows=10',
dataType: "jsonp",
jsonp: 'json.wrf',
type:'GET',
contentType: "application/json; charset=utf-8",
crossDomain: true,
success: function(data) {
response($.map(data.spellcheck.suggestions, function(item,i) {
return {
label: item.suggestion,
value: item.suggestion
}
}));
}
});
你到底有什麼問題?嘗試記錄數據以調試Solr的返回值。 –
我無法在搜索框中打印結果..以下是我的結果 –
在成功回調中使用console.log(data) –