I have this piece of code:
var suggest=$.ajax({
cache: true,
type: 'GET',
url: solrServer + "suggest?q=" + valore + ec + "wt=json&omitHeader=true&json.wrf=?",
dataType: "jsonp",
success: function (data) {
data = parse();
function parse() {
var parsedQueries = [];
for (var i = 0; i < data.spellcheck.suggestions[1].suggestion.length; i++) {
console.log('i_esimo: ' + data.spellcheck.suggestions[1].suggestion[i]);
parsedQueries[i] = data.spellcheck.suggestions[1].suggestion[i];
}
return parsedQueries;
}
}
});
console.log('suggest: ' + suggest);
when i print in console:
console.log('i_esimo: ' + data.spellcheck.suggestions[1].suggestion[i]);
I visualize all element of response and after i assign it at array parsedQueries, finally return parsedQueries, that should be assigned to my var suggest, but when i print in console suggest, i have:
suggest: [object Object]
and not my array of value. The question is: how do I return an array of values (string) from 'success' of jQuery.ajax() ???