Auto Refresh DIV contents every 5 seconds code not working

前端 未结 1 601
时光说笑
时光说笑 2020-12-19 18:32

Im using Spring MVC In My editStatus.jsp I have the following code to refresh a DIV every 5 seocnds

function refreshDiv(){
     $.ajax({
        url: \'edi         


        
相关标签:
1条回答
  • 2020-12-19 19:13

    I think your refresh function is incomplete, for instance there's nothing that makes it loop. Try something like this:

    $(document).ready(function () {
        var seconds = 5000; // time in milliseconds
        var reload = function() {
           $.ajax({
              url: 'editStatus.jsp',
              cache: false,
              success: function(data) {
                  $('#refreshDIV').html(data);
                  setTimeout(function() {
                     reload();
                  }, seconds);
              }
           });
         };
         reload();
    });
    
    0 讨论(0)
提交回复
热议问题