Answer the question
In order to leave comments, you need to log in
After a few iterations ajax -error, what's the problem?
Hello, an AJAX is executed every 15 seconds, after some time an ubderfiend error appears. How to get rid of this error?
function news() {
var msg = $('#formx').serialize();
for(var i = 1; i < 1000; i++) {window.clearInterval(i);}
var newstimer = window.setInterval('news();', 15000);
$('#conn').addClass('progress');
$.ajax({
type: 'POST',
url: '/a/new.php',
data: msg,
success:function(data) {
$('#conn').html(data);
},
complete: function() {
// indicator deactivation
$('#conn').
},
error: function(xhr, str){
alert('An error occurred: ' + xhr.responseCode);
}
});
}
Answer the question
In order to leave comments, you need to log in
Instead of generating a bunch of delayed calls
needs to be called once
Do you understand that after the first delayed news() call after 15 seconds, this function will be called 2 times, after the next 15 seconds 4 times, and so on exponentially 2 n ?
var newstimer = window.setInterval(function(){news();}, 15000);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question