You donβt want to βdelayβ the code because it blocks the browser flow, making your browser inoperative until your script timeout expires.
You can configure events that listen to a signal that has passed after a while. jQuery .bind() and .trigger() are what you want http://api.jquery.com/trigger/
Or you can use the callback function to work with the data you want after being ellapsed. So, if you intended to be like this:
function myFunc() { doStuff(); result = delayProcess(5000); $('#result').html(result); } function delayProcess(delay) {
There should be something like this:
function myFunc() { doStuff() delayProcess(5000, function(result){
source share