Ado Ado - 3 months ago 23
reST (reStructuredText) Question

JavaScript REST retrieve elements

I have a result from Fiddler (please see the attached image), how can I get the results where the arrow is pointing to?
This is what I have done so far and thank you:

arrow

function GetRefiners() {
$.ajax({
url: "myUrl",
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
},
success: function(data){
$.each(data.d.query, function(list){
});
},
error: function(error){
alert("Error message\n" + JSON.stringify(error));
}
}
);


}

Answer

Simply go to the results objects and iterates over it

function GetRefiners() {
    $.ajax({
    url: "myUrl",
    type: "GET",
    headers: {
        "accept": "application/json;odata=verbose",
    },
        success: function(data){
            $.each(data.d.query.PrimaryQueryResult.RefinementResults.Refiners.results.Entries.results, function(list){
                callWhatYouNeed();
           }
        };
   },
       error: function(error){
           alert("Error message\n" + JSON.stringify(error));
      }
    }
  );
}