Problem with setTimeout "not defined"!

problem with setTimeout function "not defined"!

What is the problem with this code?

$(document).ready(function(){ function ISS_NextImage() { //ImageSlideShow NextImage $('.ImageSlideShow').each(function() { alert($(".correntImage", this).text()); }); } var t=setTimeout("ISS_NextImage();",1000); }); 
+4
source share
5 answers

When you eval code, this is done in a global scope. Since the function you are trying to call is locally restricted, this fails.

Pass the setTimeout function instead of passing the string eval ed.

 var t=setTimeout(ISS_NextImage,1000); 
+11
source

Try changing your dialing timeout:

 var t=setTimeout(function(){ISS_NextImage();},1000); 
+3
source

Avoid passing strings to setTimeout (). Just pass the link to the function:

 var t = setTimeout(IIS_NextImage, 1000); 
+1
source

you also can:

 $(function() { var t = setTimeout(new function() { $('.ImageSlideShow').each(function() { alert($(".correntImage", this).text()); }); }, 1000); }); 
0
source

You can do something like this:

 $(document).ready(function(){ setTimeout(ISS_NextImage,1000); }); function ISS_NextImage() { $('.ImageSlideShow').each(function() { alert($(".correntImage", this).text()); }); } 
0
source

All Articles