Answer the question
In order to leave comments, you need to log in
How to create a global variable?
There is an ajax request
//ajax под грузка сообщений на странице поста
function getMessages() {
$.ajax({
url: "ajax/postComments.php",
method: "POST",
data: ({postID: <?php echo $id ?>}),
dataType: "html",
success: function (data) {
$('.author-messages-list').empty();
$('.author-messages-list').append(data);
}
});
}
var timer = getMessages();
var timerPostAuthor = setInterval(function() {
getMessages();
}, 2000);
//Останавливаем таймер на странице поста
$(document).on('keyup change', '#posttext', function () {
clearInterval( timerPostAuthor );
});
$(function () {
//ajax под грузка сообщений на странице поста
function getMessages() {
$.ajax({
url: "ajax/postComments.php",
method: "POST",
data: ({postID: <?php echo $id ?>}),
dataType: "html",
success: function (data) {
$('.author-messages-list').empty();
$('.author-messages-list').append(data);
}
});
}
var timer = getMessages();
var timerPostAuthor = setInterval(function() {
getMessages();
}, 2000);
});
//Останавливаем таймер на странице поста
$(document).on('keyup change', '#posttext', function () {
clearInterval( timerPostAuthor );
});
$('#posttext').on('change', function () {
clearInterval(timerPostAuthor);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question