Cycle plugin and setTimeout or setInterval

Cycle plugin and setTimeout or setInterval

Hi,

I'm using the cycle plugin from malsup to cycle images that are scheduled for certain times. This means I have been using setInterval or setTimeout to make a json request to retrieve new images if they are scheduled for the current time and then cycling through them. How do I incorporate the cycling of images not to restart after each successive call from setInterval or setTimeout.

The code I am using is:
  1. $(document).ready(function() {
           
        function update() {
            var update = 'update URL';
            $.getJSON(update, function(json) {
                img = json.images;




  2.             // if images have been retrieved e.g. they are scheduled for the current time
  3.             // img will consist of a bunch of img tags
                if (img) {
                    $('.collection-images-wrapper').empty();
                    $('.collection-images-wrapper').append(img);
                }
                $('.collection-images-wrapper').cycle({
                    fx: 'fade'
                });               
            });
        }
        update();
        setInterval(update, 600000);
    });













Cheers.