0
I have the following code in jquery:
musicas: function(){
$.ajax({
url: 'assets/includes/oloco.php',
type: 'GET',
dataType: 'json',
beforeSend: function(){
efeito.inicio();
},
success: function(data){
$('.texto').html(data[0].musica);
efeito.fim();
}
}),
setTimeout(function(){
player.musicas();
}, 15000);
}
And in html as seen I have:
<div class="text"></div>
However, my current ajax only changes the text of div, I would like to add 5 Divs changing the date[]! The oloco.php request is in json and has exactly 5 values as you can see below:
[
{
"musica": "Luan Santana Acordando o Pr\u00e9dio - Make U Sweat Remix (Lyric Video)"
},
{
"musica": "Kygo ft. Parson James - Stole the show (Lyrics video)"
},
{
"musica": "Justin Bieber Ft Daddy Yankee y Luis Fonsi - Pasito a Pasito Suave Suavecito (Letras)"
},
{
"musica": "Jhef - Vida M\u00edtica (Official V\u00eddeo)"
},
{
"musica": "Jhef - Pode ser n\u00f3s dois (Official Video)"
}
]
How can I insert multiple Ivs with different values and in order?
And how can I just update in setTimeout instead of adding more Divs?
– Paulo Sérgio Filho
What do you mean? You want a song added every 15 minutes?
– Woss
That way every 15 minutes you add new <p> with the same songs, you know? I would like you to add just by entering the site and then just update the contents of the site...
– Paulo Sérgio Filho
It’s not clear enough yet. You want that, when accessed the page, the 5 songs are inserted and after 15 minutes these songs change to the new ones that return from the AJAX request?
– Woss
It’s like, there are 5 songs, but they update the names every time... With the append are added 5 Divs every 15 seconds, resulting numerous texts... I want from the first time added just update your content (html) instead of continuing to trigger....
– Paulo Sérgio Filho
Every 15 seconds it is inserting new Ivs causing this: http://prnt.sc/f5o0za
– Paulo Sérgio Filho
After entering the site I just want to update the contents of the site (instead of adding new ones with the append)...
– Paulo Sérgio Filho
Roger. I edited the answer to fix this.
– Woss
Thank you so much for your attention, friend, you’re a show.
– Paulo Sérgio Filho
I believe that this code will already do that, will update without adding. This snippet ensures this: // Deletes possible previous songs: $('.text'). html("");
– Felipe Coelho