Jump to content

Global veriable outside Json


rx3mer

Recommended Posts

Hi guys,

 

I am trying to build a simple web app that takes data from database, converts it into jason and inserts the data into a veriable that should act as a playlist.

I want to make the veriable called "songs" to be equals the result and insert it into ytplayer_playlist.

 

Any guides will be very helpfull!

var songs;
function addsongs(event) {
    $.ajax({
       url: 'post.php',
       success: function (response) {
        
            var url="http://localhost/xampp/websites/youtubeAPI/post.php";

            $.getJSON(url,function(data){
            $.each(data.members, function(i,song){

            result = (song.SongUrl);
            console.log(result);

      });
    });
   }
});
}


ytplayer_playlist.push('tGvHNNOLnCk');
Link to comment
https://forums.phpfreaks.com/topic/286148-global-veriable-outside-json/
Share on other sites

the veriable called "songs" to be equals the result

Looks like it should be an array and then you can .push the URLs or whatever into it.

var songs = [];
songs.push(result);

and insert it into ytplayer_playlist.

What does "insert" mean? The .push you have down below? Copy that.

ytplayer_playlist.push(result);
And now the songs variable looks extra because you're inserting directly into the ytplayer thing? Or do you need it yourself somewhere?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.