How to run and repeat functions in same time in jQuery -


i use 2 functions. first 1 going load files folder 'img', other 1 going display them. basicyly first 1 must repeat every 30s load new images if appear. other going show images time...

problem begun when displayimages function want show them not exist yet in #listing div...

$(document).ready( function() {      setinterval(loadimages(),30000);     settimeout(displayimages(),2000);  });  function loadimages()     {          $.ajax({             url: "./img",             success: function(data)             {                 $('#listing').html('');                  $(data).find("a:contains(.jpg)").each(function(){                     // loop through                      var images = $(this).attr("href");                     $('#listing').append('<img src="img/'+images+'">');                  });                 }                });     }  function displayimages()     {         $('#listing').cycle();     } 

remove () when call settimeout or setinterval, invoke function immediately!

setinterval(loadimages,30000); settimeout(displayimages,2000); 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -