Solved

Jquery wait

Posted on 2009-06-29
3
11,165 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

689 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