How to change this ajax code to long polling [duplicate]
问题 This question already exists : How to change from ajax polling to long polling [duplicate] Closed 6 years ago . 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); 回答1: You have to put the next