ajax starts getting delayed responses

after the page being open for some time this ajax request gets a lot slower or doesn't work

 $.ajax({  
  type: "POST",  
  url: "atuamae.org/send.php",  
  data: dataString,  
  success: function() {  
  showmessages()
  //podia-se meter o texto desaparecer suavemente por baixo..
  }  
 });  

there is also this other function runing:

  function showmessages(){
  $("#messages").load('atuamae.org/show-messages-encomendar.php');
   setTimeout('showmessages()',15000);
  }

are they interfering with each other? is data being accumulated somehow?

p.s. for some reason this affects are more significant in chrome than in Firefox

Answers


Each time you call showmessages() yourself or make that ajax call which calls it, it starts a new loop of calling showmessages() every 15 seconds.

So, if you call that ajax call 10 times, you will end up with 10 timers calling showmessages() every 15 seconds. If you call the ajax call 30 times, you will end up with 30 timers calling showmessages() every 15 seconds which means it will be being called every 1/2 second. Yes, things would slow down a lot.

Do you really means for showmessages() to call itself indefinitely every 15 seconds?


Need Your Help

Asynchronous web server in java

java gwt websocket comet

I am going to develop a web applications which heavily uses push technologies like comet, websockets, etc. On the server side I want to use Java, on the client side I want to use GWT. I have taken ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.