如何定期触发Ajax请求?<meta http-equiv="Refresh" Content="5">此脚本每5秒重新加载或刷新页面。但是我想使用jQuery和Ajax调用来完成它。有可能吗?
3 回答
汪汪一只猫
TA贡献1898条经验 获得超8个赞
setTimeout()
setInterval()
function executeQuery() { $.ajax({ url: 'url/path/here', success: function(data) { // do something with the return value here if you like } }); setTimeout(executeQuery, 5000); // you could choose not to continue on failure...}$(document).ready(function() { // run the first time; all subsequent calls will take care of themselves setTimeout(executeQuery, 5000);});
慕虎7371278
TA贡献1802条经验 获得超4个赞
setTimeout
setInterval
.
- 3 回答
- 0 关注
- 626 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消