ReferenceError SetInterval not defined
javascript, setinterval, undefined
Solution
var t = SetInterval(nextSlide(),3000)
^ ^^
You have 2 problems
There is no SetInterval, the s is lowercase. Second, you are calling the function `nextSlide()`, not assigning it
var t = window.setInterval(nextSlide, 3000);
Problem
Nearly all the SetInterval errors I've seen here on StackOverflow are due to passing a function name as a "string," but maybe I am still missing some sort of variable scope problem. Please advise! I'm creating a slideshow with pause and play capabilities. When playing, I want the slides to advance every 3 seconds. But the SetInterval to launch the NextSlide function is failing after executing once. I've tried it as... ``` SetInterval("nextSlide()", 3000) SetInterval(nextSlide(), 3000) var t = SetInterval(nextSlide(), 3000) var t = SetInterval(function(){nextSlide(), 3000) ``` ... with failure every time. What am I missing here? ``` var slide_1 = "slide_1"; var slide_2 = "slide_2"; var slideNum = 0; var odd = true; var totalMax = 6; var busy = false; var allSlides = new Array(); allSlides[0] = "test_01"; allSlides[1] = "test_02"; allSlides[2] = "test_03"; allSlides[3] = "test_04"; allSlides[4] = "test_05"; allSlides[5] = "test_06"; allSlides[6] = "test_07"; function PlaySlide(){ var t = SetInterval(nextSlide(),3000) document.getElementById("play").style.visibility = "hidden"; document.getElementById("pause").style.visibility = "visible"; } function nextSlide(){ if(slideNum < totalMax && !busy){ busy = true document.getElementById("loading").style.zIndex = 4; slideNum = slideNum + 1 var slide = allSlides[slideNum] var link = "https://dl.dropboxusercontent.com/u/..." + slide + ".jpg" odd = !odd if(odd){document.getElementById(slide_1).src = link} //which <img>.onLoad lauches a fadeIn() else{document.getElementById(slide_2).src = link} } } ```