Solved

Jquery wait

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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)

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now