set Interval function is not working in jsp?

The setInterval function is not working in my jsp page, below is my code:-

<script>
    $(document).ready(function(){

        $('form[name="lgform"]').submit(function(evnt){
            evnt.preventDefault();

        try{
            mapPlotVar.clearInterval();
            }
            catch(e)
            {
            }
            mapPlotVar=setInterval($("#btn_login").click(function(){console.log("update");},20000));

        });

        $("#btn_login").click(function(){

             alert("hi");

        });

    });

    </script>


    <body>

    <form name="lgform">
    <div>

    <table id="table"  >
        <tr>

            <td width="35px"><input id="mob"  type="text" name="mob_nu" placeholder="1234567890"  maxlength="10"></td>

            <td width="100px"><input type="button" name="login_btn" id="btn_login" value="Login"></td>

            <td width="100px"><label for="Login" style="color: red" id="login_val"></label></td>

        </tr>

    </table>
    </div>
    </form>

    </body>
    </html>

After clicking the “btn_login” once i want the function to be called after every 20 seconds so that i get the alert message “hi” after every 20 seconds, but “hi” is only showing once, setInterval function is not working. What is wrong with my code? Any piece of code is appreciated.
Thanks in advance


Source: jsp

Leave a Reply