URL==>> http:/localhost:8080solrTestsuggest?indent=true&wt=json&q=how。
{
"responseHeader":{
"status":0,
"QTime":2},
"spellcheck":{
"suggestions":[
"how",{
"numFound":5,
"startOffset":0,
"endOffset":3,
"suggestion":["how to tie a tie",
"how to get away with a murderer",
"how to boil eggs",
"how to lose weight",
"how to make money"]}]}}
我得到的是上面的json格式,如何用jquery获取这个响应?
I got my answer, I was looking this solution
$.ajax({ url: "http://localhost:8080/solr/Test/suggest",
dataType: "json",
success: function( data ) {
var suggestions = (data.spellcheck.suggestions &&
data.spellcheck.suggestions.length > 1) ?
data.spellcheck.suggestions[1].suggestion : [];
for (var d=0; d < suggestions.length; d++) {
var doc = suggestions[d];
}
所有的建议值都在doc变量中