What's new

Closed Javascript

Status
Not open for further replies.

Vosfows

Addict
Joined
Feb 5, 2019
Posts
122
Reaction
10
Points
102
Hello po, baka matulungan niyo po ako sa problem ko hahaha

Gusto ko po sana ipasok itong code na ito
JavaScript:
data.items.forEach(item => {
          music = `
          <iframe  src="

        let src_str = `https://open.spotify.com/embed/track/
${items.id}" frameborder="0" allowfullscreen></iframe>

          `
          $("#music-video").append(music)
}

Dito ko po ipapasok, paano po kaya yun?
Code:
$.ajax({
   url: newUrl,
   type: "GET",
   headers : {
   "Authorization" : "Bearer" + accessToken}
   },
   success: function(response) {
   (DITO KO PO SANA ILALAGAY YUNG CODE SA TAAS)
       console.log(response);
   }
});


Hidndi po kasi dunction method yung ipapasok ko, hindi ko po kasi alam kung paano ko ididisplay yung output na naka iframe hahaha

TIA :)
 
Sa unang code mo hindi ma data.items palitan mo ng response.item kasi ayun nilagay mo dito

success: function (response)

Kaya ma access mo sya using response word
 
Sa unang code mo hindi ma data.items palitan mo ng response.item kasi ayun nilagay mo dito

success: function (response)

Kaya ma access mo sya using response word
ayy haha opo pala sorry di ko napalitan nagawa ko na po data yung sa success:function ko, pero po kapag nilagay ko yung code ng data.items sa loong ng success:function hindi po gumagana
 
bale ganito po ginawa ko nung una kaso ang nakukuha ko lang din pong output eah iisa kasi naka specify po sa let id ko na item[0] haha kaya po naisipan ko gumawa ng forEach para po sana mag loop sa lahat ng output kaso di ko po malagay sa loob ng success:function kasi di daw po function yung method ko hahaha


JavaScript:
success: function(data) {
        $("#music").empty();
        //console.log(' ');
        //console.log(' ');
        //console.log('Got data back');
        // Let's console what gets returned for our search
        console.log(data);
        // Example: Extract the id of the song from the data object
        let id = data.tracks.items[0].id;
        console.log(' ');
        console.log(`id ${id}`); ////id 1TEL6MlSSVLSdhOSddidlJ
        // Constructing a iframe to embed a song
        let src_str = `https://open.spotify.com/embed/track/${id}`;
        console.log(`src_str ${src_str}`);
        let iframe = `<iframe src=${src_str} frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>`;
        let parent_div = $('#music');
        parent_div.append(iframe);

      }
 
Status
Not open for further replies.

Similar threads

Back
Top