I'm working on a wordpress editor where I need to be able to refresh images without having to reload the page. However, I'm not getting the plot as I'm not really a javascript master :(
I'm running this, but in the console log, all I get is: "Uncaught ReferenceError: updateImage is not defined". What am I doing wrong?
<script>
    var newImage = new Image();
    newImage.src = "http://2famous.tv/wp-content/uploads/2013/07/Dubai-Sky-scrapers_thumb_one.jpg";
    function updateImage() {
    if(newImage.complete) {
        document.getElementById("thumb1").src = newImage.src;
        newImage = new Image();
        newImage.src = "http://2famous.tv/wp-content/uploads/2013/07/Dubai-Sky-scrapers_thumb_one.jpg?" + new Date().getTime();
    }
        setTimeout(updateImage, 1000);
    };
</script>
<img id="thumb1" src="image.jpg" onload="updateImage();">
 
    