Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to call function after timeout function is done?

I have a function with a timer, I want to call another function when the timer of the another function is done, so the first function will show a modal for 3 seconds, and the another funciton will show another modal, here is my code:

var fn = setTimeout(function(){
    $('#responseModal').modal('hide');
    return true;
}, 3000);

if(fn)

    $('#requestModal').modal('show');
like image 541
MD.MD Avatar asked Sep 03 '26 04:09

MD.MD


1 Answers

Wouldn't

setTimeout(function(){
    $('#responseModal').modal('hide');
    $('#requestModal').modal('show');
}, 3000);

do the trick?

No need to return anything in the callback function for setTimeout. It's meaningless.

like image 182
spender Avatar answered Sep 04 '26 18:09

spender



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!