Auto update div content loaded by jquery includes ajax call
I am loading the output from now_playing.php
(shout is now playing content) using jQuery include ajax call like sugested here and it works well.
My code:
<script>
$(function(){
$("#now_playing").load("now_playing.php");
});
</script>
<div id="now_playing"></div>
I just need the content of the output div to update every 5 seconds or so. What code can I add to a script or div for this? Thank!
+3
source to share
4 answers
Found out the suggestions of Magicprog.fr, augustoccesar and Edan Feiles and decided that the Magicprog.fr solution is best because it loads output_playing.php first and then just updates it at a given interval:
<script>
function loadNowPlaying(){
$("#now_playing").load("now_playing.php");
}
setInterval(function(){loadNowPlaying()}, 5000);
</script>
Many thanks for the help:)
0
source to share