S
S
shnicel2016-02-23 18:04:09
JavaScript
shnicel, 2016-02-23 18:04:09

Why are var empty after audio.get method?

var urlSong = '';
var titleSong = '';
var artistSong = '';
var durationSong = '';

VK.api('audio.get', {count:1}, function(audio) {
    //console.log(audio.response[0].url);
    urlSong = audio.response[0].url,
    titleSong = audio.response[0].title,
    artistSong = audio.response[0].artist,
    durationSong = audio.response[0].duration
})

var Playlist = [
    {
        mp3:urlSong,
        title:titleSong,
        artist:artistSong,
        duration:durationSong
    }

];

This is how I try to shove the answer received by VK into var, but it even went wrong and does not work, what's the jamb?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2016-02-23
@miraage

The question of asynchrony has already been raised 1000 times. Learn to use search.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question