JS-函数执行后延迟重新加载位置 [英] JS - location reload with delay after function executed

查看:50
本文介绍了JS-函数执行后延迟重新加载位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行JS/AJAX脚本来更新表中的数据,一旦脚本完成,我想重新加载页面.但是,使用我当前的代码,它会立即重新加载,是否可以将重新加载时间延迟3秒?

I am running a JS / AJAX script to update data in my table and once the script is done, I would like to reload the page. However, with my current code, it reloads immediately, is there any way to delay the reload for 3 secs?

// close modal and refresh page
$('#EditRecordModal').modal('hide');
location.reload();

谢谢

推荐答案

$('#EditRecordModal').modal('hide');
setTimeout(function(){location.reload()}, 3000);

这篇关于JS-函数执行后延迟重新加载位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆