I'm trying to work through a question previously asked on stckoverflow - "Using AJAX / jQuery to refresh an image"
Using AJAX / jQuery to refresh an image
The URL from image_feed.php is supposed to change everytime. However, I can't figure out what the code for image_feed.php should be (even an example). Can anyone help?
FYI, my index.php is:
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function() {
var $img = $('#image1');
setInterval(function() {
$.get('image_feed.php?CAMERA_URI=<?=$camera_uri;?>', function(data) {
var $loader = $(document.createElement('img'));
$loader.one('load', function() {
$img.attr('src', $loader.attr('src'));
});
$loader.attr('src', data);
if($loader.complete) {
$loader.trigger('load');
}
});
}, 5000);
});
</script>
</head>
<body>
<div id="image1">
</div>
</body>