Solved

Jquery wait

Posted on 2009-06-29
3
11,153 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

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
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)

809 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