I have a online radio station and i wanted to show a album image for every song.Since I have the ability to automatically upload an image of a current playing song (artwork.png) to a web server via ftp, i made a script to display the image on html page..
My Code:
<div id="auto">
<img id="artwork" src="artwork.png"></img>
</div>
function refresh() {
setTimeout (function() {
var timestamp = new Date().getTime();
$('#auto').html('<img src="artwork.png?timestamp='+ timestamp +'"></img>');
refresh();
}, 1000);
}
$('#artwork').attr('src', 'artwork.png?timestamp=' + new Date().getTime());
Everything works great except auto refresh, so i have to manually refresh the page to load a new replaced image. But i want whenever a new image is uploaded to do one refresh on div and that's it. Where is the problem here with refresh();