Am trying to invoke a function after the loading of the html page. Its working fine and I want the function to be invoked after every 3 seconds and hence inserted the setInterval() for it. But the function is not at all getting called. Is there any problem with the syntax of setInterval()..?
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">
</script>
<script>
$(document).ready( setInterval(function(){f()},3000); );
function f()
{
xhttp=new XMLHttpRequest();
xhttp.open("GET","/anu/get.php",true);
xhttp.send();
xhttp.onreadystatechange = function(){
if(xhttp.readyState==4){
var Display = document.getElementById('new');
Display.innerHTML = xhttp.responseText;
}
}
}
</script>
</head>
<body>
<p id="new"> </p>
<body>
</html>
See Question&Answers more detail:os