I am trying to call a function repeatedly after a certain amount of time delay with the help of java script.

<html>
<head>
<script type="text/javascript" src="prototype.js"></script>
		<script>

			function sendRequest() 
                        {
				Something to do
			}
		</script>
</head>
<body>
<script type="text/javascript">
 setTimeout ( "sendRequest()", 2000 );
</script>
</body>
</html>

If i use any infinite for loop before line 14 then my browser giving warning...!!
What to do??

Recommended Answers

Use setInterval() method instead of setTimeout(). setInterval will repeatedly call a function at given interval

setInterval("sendRequest()", 2000 );
Jump to Post

All 2 Replies

Use setInterval() method instead of setTimeout(). setInterval will repeatedly call a function at given interval

setInterval("sendRequest()", 2000 );

thanks a lottttt.!!!!Its working Great ..!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.