In some common ways, you'd have to either do it: setTimeOut(function() { window.location = 'http://www.google.com'; }, 5000);
or: setTimeOut(doSomething, 5000); doSomething() { window.location = 'http://www.google.com'; } or: setTimeout('window.location = "http://www.google.com"', 5000); On Mar 31, 2:28 pm, MonkeyBall2010 <hughes.timo...@gmail.com> wrote: > setTimeout(window.location = "http://www.google.com", 5000); > > It seems that the script just completely ignores the timeout but > executes the code anyways... What is really weird is that if I put > some other code on a timer then it works correctly so maybe I am doing > the redirect wrong?? > > On Mar 30, 9:38 pm, James <james.gp....@gmail.com> wrote: > > > Can you show us how the "//redirect" part of the code looks like? > > It should be on the lines of something like: > > > setTimeOut(function() { > > location.href = '/somepage'; > > > }, 2000); > > > On Mar 30, 4:05 pm, MonkeyBall2010 <hughes.timo...@gmail.com> wrote: > > > > Yeah, that was just a typo on my behalf... The actual code does list > > > the correct code... Any idea what I am doing wrong? > > > > On Mar 27, 1:17 pm, James <james.gp....@gmail.com> wrote: > > > > > Javascript is case-sensitive: > > > > 'setTimeOut' should be 'setTimeout' > > > > > On Mar 26, 5:08 pm, MonkeyBall2010 <hughes.timo...@gmail.com> wrote: > > > > > > I am using the validation plugin and the form plugin to validate my > > > > > form and then submit the information via ajaxSubmit. I have everything > > > > > working with the exception of my success callback function. Once the > > > > > form is successfully validated I just want to wait about 2 - 3 seconds > > > > > to run a script and then redirect the user to a new page. This works > > > > > but the code is executed immediately: > > > > > > var options = { > > > > > success: createAccount, > > > > > clearForm: true > > > > > > }; > > > > > > $("#submitForm").validate({ > > > > > rules: { > > > > > //Insert Rules Here > > > > > }, > > > > > messages: { > > > > > //Insert Messages Here > > > > > }, > > > > > submitHandler: function(form) { > > > > > jQuery(form).ajaxSubmit(options); > > > > > } > > > > > }); > > > > > > function createAccount () { > > > > > //Do Stuff > > > > > setTimeOut(//Redirect, 2000); > > > > > > } > > > > > > So instead of waiting 2 seconds to redirect the code is executed as if > > > > > the timer isn't even there!! Can anyone please help me with this? I > > > > > have tried everything and still the timer does not work!!- Hide > > > > > quoted text - > > > > > - Show quoted text -- Hide quoted text - > > > - Show quoted text - > >