This is my ajax code so please can anyone tell me how can i change this code to long polling ?
Here is my code :-
var chat = {}
chat.fetchMessages = function () {
$.ajax({
url: 'ajax/ajax/chat.php',
type: 'POST',
data: { method: 'fetch' },
success: function(data) {
$('#chats').html(data);
}
});
}
chat.interval = setInterval(chat.fetchMessages, 1000);