jquery使用ajax实现实时刷新,轮询
来自:https://blog.csdn.net/qq_25406669/article/details/78343082
var isLoaded = false; function reqs() { $.ajax({ type: 'get', url: 'demo.php', dataType: 'json', beforeSend: function() { isLoaded = false; }, success: function(res) { console.log(res); }, complete: function() { isLoaded = true; }, error: function() { console.log('请求失败~'); } }); } reqs(); setInterval(function() { isLoaded && reqs(); }, 3000);