Link to home
Start Free TrialLog in
Avatar of AndyPSV
AndyPSVFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Jquery wait

I want to make my script wait for 4 seconds after performing an action.

Typically it works like this perfect:
...
            });
                  },
                  onComplete: function (a, b ,c, d, e) {
                        var size = Math.round(c.size/1024);
                        $.jGrowl('<p></p>'+c.name+' - '+size+'KB', {
                              theme:       'success',
                              header: 'Upload Complete',
                              life:      4000,
                              sticky: false
                        });
                        window.location.replace('<% $URL %>profile/photo');
                  }
            });
...

I want to delay: " window.location.replace('<% $URL %>profile/photo'); "
4 seconds

how to do it?
ASKER CERTIFIED SOLUTION
Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AndyPSV

ASKER

:*
 });
                  },
                  onComplete: function (a, b ,c, d, e) {
                        var size = Math.round(c.size/1024);
                        $.jGrowl('<p></p>'+c.name+' - '+size+'KB', {
                              theme:       'success',
                              header: 'Upload Complete',
                              life:      4000,
                              sticky: false
                        });
                       //===========================================
                       // reference from Javascript
                       sleep(4000);
                       //===========================================
                        window.location.replace('<% $URL %>profile/photo');
                  }
            });