我有这段代码:
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);
当我在控制台中打印时:
console.log('i_esimo: ' + data.spellcheck.suggestions[1].suggestion[i]);
我将响应的所有元素可视化,在我将它分配给数组 parsedQueries 之后,最后返回 parsedQueries,它应该分配给我的 var 建议,但是当我在控制台建议中打印时,我有:
suggest: [object Object]
而不是我的价值数组。问题是:如何从 jQuery.ajax() 的“成功”返回一个值数组(字符串)???