1
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
  $(document).ready(function() {     
    var refreshId = setInterval(function() {
      $("#curl-refresh").load('test-xml.php');
    }, 30000);
    $.ajaxSetup({ cache: false });
  });
</script>

I am trying to refresh the div content without refreshing the whole page. I'm getting the desired output, but the browser hangs after some time.

I have seen similar questions, but none of them helped me. Please help me out

My question is similar to this: Auto refresh div causing browser to hang

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
andy
  • 97
  • 1
  • 9
  • 3
    I can't help with the specifics of your issue, but AJAX polling is an anti-pattern. Aside from killing resources on the client, it is effectively DDOSing your own server if you have any decent number of users. You should look in to using WebSockets or Server Sent Events instead, assuming your goal here is to keep the UI and server state in sync – Rory McCrossan Jul 04 '17 at 08:38
  • 1
    You should look in to web sockets.. sending ajax request every 3 seconds u are at somehow sending DDos attacks to your own server without noticing have a look at [sockets.io](https://socket.io/) – Masivuye Cokile Jul 04 '17 at 08:42
  • could you all help me how to proceed – andy Jul 04 '17 at 08:44
  • can't we add/remove on the code above,suggest some solution as this is already working – andy Jul 04 '17 at 09:01
  • any help on this – andy Jul 04 '17 at 09:12

1 Answers1

0

Sometimes you can't prevent browser from caching in that case you can use some url query random parameter to prevent caching to be happen. some like :

var url = "test-xml.php?" + Math.random();

or

var url = "test-xml.php?" + new Date().getTime();
nullqube
  • 2,959
  • 19
  • 18