Hi all,
I am trying to call setInterval() on onclick event. But it is executing the code only once. Following is my code.
<script type="text/javascript" language="javascript"> var xmlHttp; function postRequest() { if (typeof XMLHttpRequest != "undefined"){ xmlHttp= new XMLHttpRequest(); }else if (window.ActiveXObject){ xmlHttp= new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlHttp==null){ alert ("Browser does not support XMLHTTP Request") return } var url="/AutoDialer/two.jsp"; xmlHttp.onreadystatechange = stateChange; xmlHttp.open("GET", url, true); xmlHttp.send(null); } function stateChange(){ if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ document.getElementById("display").innerHTML=xmlHttp.responseText; } } function send(){ // alert("send"); var a=setInterval(postRequest(),3000); //alert(a+"=: "+a); } </script> <body> <div id="one" onClick="send();"><a href=""><span class="hyper">On Call Report</span></a></div> </body> </html>
Here this code is executing two.jsp only once. And ready state is always 1. Please help me in resolving this problem.