0

jsp code:

<div id="myRefreshKBD">
Current Time :<%= new java.util.Date() %>
</div>

javascript code:

$(document).ready(
            function() {
                setInterval(function() {                    
                    $('#myRefreshKBD').html('I am getting refreshed every 3 seconds..');
                }, 3000);
            });

My question here is whenever refreshing myRefreshKBD id from js, date should refresh...Expecting a great answer. It is sticking much now.

RockAndRoll
  • 2,247
  • 2
  • 16
  • 35

1 Answers1

0

The code is fine.You just need to add jquery library like this.

<script src="http://code.jquery.com/jquery-latest.min.js"></script>

and you need to change your javascript like this

$(document).ready(
        function() {
            setInterval(function() {    
                $('#myRefreshKBD').html('Current Time : '+new Date());
            }, 3000);
        });

jQuery uses "$" as a shortcut for "jQuery".So if you want to use jQuery without downloading,use above one or you can download it and add it in your project.

See Also

Community
  • 1
  • 1
RockAndRoll
  • 2,247
  • 2
  • 16
  • 35
  • thanks prince for your replay. My target to refresh the content in the div. for sample i put Current Time :<%= new java.util.Date() %>. Actually i have some session variables in the div of the jsp. From js i want to refresh it and display with new values – vsasikumar Oct 12 '15 at 14:02
  • updated my answer.I think this is what you are looking for.see the link.I hope it helps. – RockAndRoll Oct 12 '15 at 15:14
  • Thanks prince it is useful. I tired this way. But no luck on this.
    here the sessionScope.MODULE_NS.pageDetails.moduleList variable is not updating once ajax call happen. am not passing response from ajax. In ajax am updating MODULE_NS.pageDetails.moduleList value. Based upon ajax response flag am refresh the exisiting div. load function also not helpful to load jsp inside WEB-INF folder.
    – vsasikumar Oct 13 '15 at 07:26