Hello I get the following Javascript error when calling goon() within a jquery function. I thought it is defined…but obviously not…?! Why not?:
goon is not defined var timeout= setTimeout(‘goon()’, 3000);
$('.rs-slideshow').stop().fadeOut('fast',function(){
$('html,body').stop().animate({
scrollLeft:$offset
}, 1000, function(){
function goon(){
$('.rs-slideshow').fadeIn('fast');
$('#slideshow').clearQueue().rsfSlideshow('startShow');
}
var timeout= setTimeout('goon()', 3000);
});
});
You are passing a String (
'goon()'as delimited by the's) to yoursetTimeoutwhich is evaluated in global scope. The function though is not accessible in global scope, it is only local to the animation callback, hence it cannot be found.Pass the reference directly instead:
Note that I also omitted the
()as this would not pass the function but execute the function and pass its returned value.