Help with Ajax
Help with Ajax
Hi all,
I have a question regarding a JSON result (to be used in Autocomplete). The JSON is divided into four different categories like this:
..
"Region":[],
"County":[],
"Parish":[{
"Suggestion":"Fuseta (Olhão)",
"Filter":"Par_17385"
}],
"Zone":[{
"Suggestion":"Fuste (Rôge)",
"Filter":"Zon_17388"
},{
...
Could anybody pleae give me a hint how to loop through the categories and collect all the Suggestions into the response. In the code below, I obviously only get the Zone items back.
source: function(request, response) {
$.ajax({
url: "...",
dataType: "jsonp",
data: {
numberOfResults: 20,
query: request.term
},
success: function(data) {
console.log(data);
response($.map(data.Zone, function(item) {
return {
label: item.Suggestion + ' ' + item.Filter,
value: item.Suggestion.replace(/()|()/g, "")
}
}))
}
})
},
I'm stuck - Thanks for your help which is highly appreciated.
Arnold