Jump to content

Global veriable outside Json


rx3mer
Go to solution Solved by requinix,

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
Share on other sites

  • Solution

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? Edited by requinix
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.