The php script parses xml file and print output on page inside div:
<?php
$playlistUrl = 'http://url/to/playlist.xml';
$xmldata = file_get_contents($playlistUrl);
$xml = new SimpleXMLElement($xmldata);
foreach( $xml->trackList->track as $track ) {
echo $track->title .' - '. $track->annotation .'<br>';
}
?>
I want to update the output every 25sec without reloading the page, using some AJAX method. I find some code samples that set time interval:
// Poll the server each 60 seconds
window.setInterval(function()
}, 60000);
also
setInterval(function(){
SomeAjaxFunction();
}, 1000);
How to implement this properly in my case?
check out my answer here.
Refresh page element after specific time
i have answered about how to reload the div after specific time, you can tweak it a bit to keep reloading after a time interval.
the basics goes as follows.
and your jQuery code.