Answer the question
In order to leave comments, you need to log in
How to combine two JavaScript codes?
So, hello everyone, there is a very interesting question in the implementation of this function there is a list of audio question how to implement the function when you click on the plus sign so that the audio is added to the list of audio recordings of the user VK
I get the list of audio like this
function recommendate(){
VK.Api.call('audio.getRecommendations', {count: '1000'}, function(r) {
if(r.response) {
$('#playlist').empty().append($.map(r.response, function(song){
return '<li><a href="'+ song.url +'"><b>'+song.artist+'</b> - '+ song.title +'<span class="label">'+ song.aid +' - '+ song.owner_id+'</span></a></li>'
}))
}
});
};
function addaudio(){
VK.Api.call('audio.add', { audio_id: 161291628, owner_id: -9880494 }, function (data) {
if (data.response) {
console.log(data.response);
}
});
};
Answer the question
In order to leave comments, you need to log in
Well, aid is contained in the song object, we shove it into the data attribute of li or a or the plus sign itself (in the example below).
On the onclick of the plus sign, we get its data-aid and call the addaudio(aid) function, passing the aid argument accordingly.
But about the id of the user to whom to add an entry to favorites, let others who are more versed in the issue answer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question