2

I am trying to call setinterval function in jQuery, but it is giving error

Microsoft JScript runtime error: 'setinterval' is undefined

Here is my code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            setInterval(function () {alert("HELLO WORLD!");}, 300);
        });
    </script>
</head>
<body>
//HTML code is here.
</body>
</html>

enter image description here

12
  • 1
    Works for me! jsfiddle.net/NsVGa (time changed so it can be easily stopped). Commented Apr 6, 2012 at 22:00
  • the code you shared is correct, I think we should see your whole code, if it's possible. Commented Apr 6, 2012 at 22:06
  • 1
    Is your script reference really src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"? If so, I think you need to prefix the URI with http:. Commented Apr 6, 2012 at 22:18
  • 2
    @halfer: Using a protocol-less URL works fine as long as you're not loading the page from a file:/// URL (in which case the protocol-less URL tries to load jQuery from that path locally instead of from the Google CDN). For more info: encosia.com/… Commented Apr 6, 2012 at 22:47
  • 1
    Are you cached with a bad version of the file. Clear the cache. Commented Apr 6, 2012 at 23:08

1 Answer 1

4

The screenshot shows that you are trying to use "setinterval", that is without the capital "i", which is a mistake (javascript is case-sensitive). Either it is not the exact code you are using, either there is another piece of code somewhere who does call it.

Sign up to request clarification or add additional context in comments.

1 Comment

It is EXACT code I am using and it is working fine in Firefox. If "i" is the issue then it should not run in Firefox.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.