Solved

Jquery wait

Posted on 2009-06-29
3
11,149 Views
Last Modified: 2012-05-07
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?
0
Comment
Question by:AndyPSV
3 Comments
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 500 total points
ID: 24742737
Hi AndyPSV,
Try this:
This line:
window.location.replace('<% $URL %>profile/photo');
                  
Change to
window.setTimeout("window.location.replace('<% $URL %>profile/photo');",4000)

Open in new window

0
 

Author Closing Comment

by:AndyPSV
ID: 31598235
:*
0
 
LVL 1

Expert Comment

by:tfy_002
ID: 25439691
 });
                  },
                  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');
                  }
            });
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question