Armitage2k Armitage2k - 2 months ago 11
Ajax Question

JS - location reload with delay after function executed

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();


Thanks

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