javascript ajax setinterval delay
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How can I execute this function immediately, then start the setInterval timer? Here is my js. $(document).ready(function(){ var callAjax = function(){ $.ajax({ method:'get', url:'apinvs.php', dataType:'html', success:function(data){ $("#main").html(data); } }); } setInterval(callAjax,2500); }); It's executing the function after 2.5 seconds. It leaves the div blank until 2.5 seconds pass, which is what I don't want to happen. :( I found a Stackoverflow question here but I'm not sure how to apply it with my code (it's using document ready).