1

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

Armitage2k
  • 966
  • 1
  • 18
  • 49
  • 2
    Possible duplicate of [How to delay execution in between the following in my javascript](http://stackoverflow.com/questions/5990725/how-to-delay-execution-in-between-the-following-in-my-javascript) – Joe Clay Sep 22 '16 at 12:21
  • Do you get a response from your database/server? You can wait until the response comes and then reload the page/display error message if not updated in database. – Dinca Adrian Sep 22 '16 at 12:28

1 Answers1

5
$('#EditRecordModal').modal('hide');
setTimeout(function(){location.reload()}, 3000);
Maxx
  • 1,600
  • 7
  • 16