javascript - Updating an image that is re-uploaded periodically -


i have webcam script sends jpg via ftp webserver every 10 seconds (overwriting original).

how can jquery refresh image? tried:

window.onload = function() {             $('body').prepend('<img id="cam" src="ww.jpg" alt="" />');             setinterval(runagain, 12500);         };          function runagain() {             $.ajax({                 url:'ww.jpg',                 cache:false,                 beforesend:function() {                     $('#cam').remove();                 },                 success:function() {                     $('body').prepend('<img id="cam" src="ww.jpg" alt="" />');                 }             });         } 

note: don't want refresh page if can it.

a dirty way appending timestamp or random number @ end of image src, prevent caching, img src="image.jpg?random=[random]" [random] timestamp or random number


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -