Using AJAX / jQuery to refresh an image --> image_feed.php code? -


i'm trying work through question asked on stckoverflow - "using ajax / jquery refresh image"

using ajax / jquery refresh image

the url image_feed.php supposed change everytime. however, i can't figure out code image_feed.php should (even example). can help?

fyi, 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> 

the image_feed.php should return image's src response.

<?php // produce src logic. $src = "https://www.gravatar.com/avatar/daa6ae7c970d99c6c2b3a9d8895aaa1e?s=32&d=identicon&r=pg"; echo $src; 

Comments