私はsolrとjqueryを使って自動挑戦をしようとしています。予期しないトークン: JSONデータIクロームJqueryを使用してJSONを解析できません
キャッチされないでSyntaxErrorで実行中に
$(関数(){
$("#artist").autocomplete({
source: function(request, response) {
$.ajax({
url: 'http://localhost:8983/solr/terms?terms.fl=heading&terms.prefix='
+request.term+'&wt=json&json.nl=map',
dataType: "jsonp",
data: {
q: request.term,
rows: 10,
omitHeader: true,
},
success: function(data) {
response($.map(data.terms.heading, function(item) {
return {
label: item,
value: item
}
}
)
);
}
});
},
minLength: 2,
select: function(event, ui) {
log(ui.item ?
"Selected: " + ui.item.label :
"Nothing selected, input was " + this.value);
},
open: function() {
$(this).removeClass("ui-corner-all").addClass("ui-corner-top");
},
close: function() {
$(this).removeClass("ui-corner-top").addClass("ui-corner-all");
}
});
});
私は、次のエラーを取得しています。このために私は以下のコードを書きました午前取得はこの
{ "用語":{ "見出し":{ "答え":24、 "アンサリ":5}}}である
は、私は次のリンクを相談 http://jqueryui.com/demos/autocomplete/#remote-jsonpしかし、私は解決策を見つけることができません。私が間違っていることを提案してください
あなたは間違っている投稿したコードで
もっと ")};"最後に。またdataType: "jsonp"ではなく "jsonp"でなくてはなりません。 – CBusBus
おそらく$ .map(data.d.terms.heading、function(item) –
を試してみてください) –