The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
How to display countdown timer for AJAX image refresh?
I have this code to refresh an image on a page every 30 seconds, it is working well:
Code:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { setInterval(function() { $('.cameraimage').attr('src', $('.cameraimage').attr('src') + '?d=' + new Date().getTime()); }, 30000); }); </script> |
#2
|
|||
|
|||
I'm not really a js expert, but this seems to work:
Code:
$(document).ready(function() { var countdown = 30; $('#countdown').html(countdown); setInterval(function() { countdown--; $('#countdown').html(countdown); if (countdown <= 0) { $('.cameraimage').attr('src', $('.cameraimage').attr('src') + '?' + new Date().getTime()); countdown = 30; $('#countdown').html(countdown); } }, 1000); }); Then you need to insert something like: Code:
<div>Image updates in: <span id="countdown"></span></div> |
Благодарность от: | ||
bzcomputers |
#3
|
||||
|
||||
Works great, thanks a lot!
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|