I'm having problems with a system that downloads the photo of 10 artists from a TOP 10. Here is the function:
function baixarCapa(capa) {
$.getJSON("https://ajax.googleapis.com/ajax/services/search/images?callback=?", {
q: '"' + capa + '"',
v: '1.0'
}, function(data) {
return data.responseData.results[0].url;
});
}
And below:
showTopMusicas: function(){
this.ajax('callCustomApi', ['getTop'], function(dados) {
if (!dados || !dados.length) {
return;
}
var html = '';
capa = '';
for (var i=0; i< dados.length; i++) {
var nome = CentovaApi.formataNomeMusica(dados[i]);
if (!nome) {
continue;
}
capa = nome.split('/').pop();
console.log(baixarCapa(capa));
html += '<tr>';
html += '<td>' + baixarCapa(capa) + '</td>';
html += '<td>' + (i+1) + 'º</td>';
html += '<td>' + nome.split('/').pop() + '</td>';
//html += '<td>' + dados[i].count + '</td>';
html += '</tr>';
}
$('#table_top_musicas').find('tbody').html( html );
}, true);
},
Everything works, with this exception of the covers, only undefined
appears.