I am currently using this ajax code and I was wondering if anyone knows how to change it to long polling.
Here is the code I am using:
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);