如何获得拼写检查器的响应json solr。

问题描述 投票:1回答:1

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获取这个响应?

jquery json solr
1个回答
0
投票
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变量中

© www.soinside.com 2019 - 2024. All rights reserved.