-3
I need to retrieve an object attribute by AJAX in a $.each(), and pass it in src of an img tag.
AJAX function:
$.ajax({
type: 'GET',
url: `user/album/recommended/`,
context: 'json',
success: function(data){
data = JSON.parse(data);
console.log(data);
var cont = 1;
$.each(data, function(index, value){
$("#album"+cont+"").append('<img src="'+value.data.cover_medium+'"/>');
cont++;
});
$(".new-album").show();
},
error: function(){
console.log('Erro no AJAX de recomendação');
},
});
console.log(data) returns this:
Could you explain to me the reason for the negative?
– Everton Neri