I had a call to each method for some results getJSON:
if(data && data.query && data.query.results)
{
$.each(data.query.results.span, function(i, item)
{
console.log("Content:" + item.content);
});
}
I could not understand why it did not display anything, although I could see that JSON returned a single result.
So, I deleted each and did the following:
if(data && data.query && data.query.results)
{
console.log("Content:" + data.query.results.span.content);
}
Now it works.
Is there no way to use each()when there is only one result?
source
share