Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-22-2011, 08:40 PM   PM User | #16
Dan13071992
Regular Coder

 
Join Date: Dec 2010
Location: Kent, UK
Posts: 573
Thanks: 23
Thanked 10 Times in 10 Posts
Dan13071992 is an unknown quantity at this point
Code:
Countdown Timer:
Database Backup in T-Minus 13 minutes 55 seconds!
and counting down, however how can i make it refresh at the end when it hits zero, so that it refreshs the page without sending any forms

i have a screen shot of what im trying to achieve if that will help at all?

Last edited by Dan13071992; 01-22-2011 at 08:42 PM.. Reason: changed the [code] tags so it was done properly
Dan13071992 is offline   Reply With Quote
Old 01-22-2011, 08:46 PM   PM User | #17
ShaneC
Codeasaurus Rex


 
Join Date: Jun 2008
Location: Redmond, WA
Posts: 659
Thanks: 31
Thanked 100 Times in 94 Posts
ShaneC is on a distinguished road
Well I'll need some more clarification, what is your intention with refreshing the page? It is possible to make the page change location (which could be to itself), however without something else on the page this is kind of pointless.

You can achieve this kind of behavior by doing this in the Javascript .get function.

Code:
if( data == "Database Backup in T-Minus 0 minutes 0 seconds!" )
     location.reload();
Obviously there's ways to spruce this up in PHP. Such as making it display "Starting Backup!" when the minutes and seconds variables hit 0. Your coding level should allow you to do this without my assistance.
__________________
Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
My posts, comments, code, and suggestions reflect only my personal views.
Web Portfolio and Code Snippets: http://shanechism.com
ShaneC is offline   Reply With Quote
Old 01-22-2011, 08:52 PM   PM User | #18
Dan13071992
Regular Coder

 
Join Date: Dec 2010
Location: Kent, UK
Posts: 573
Thanks: 23
Thanked 10 Times in 10 Posts
Dan13071992 is an unknown quantity at this point


that is what im trying to achieve, but when it hits 00:00 i would like the page to refresh itself, so that it is directed back to the same page but without sending any of the post data that was selected in order to start the timer, if that makes any sense
Dan13071992 is offline   Reply With Quote
Old 01-22-2011, 08:57 PM   PM User | #19
ShaneC
Codeasaurus Rex


 
Join Date: Jun 2008
Location: Redmond, WA
Posts: 659
Thanks: 31
Thanked 100 Times in 94 Posts
ShaneC is on a distinguished road
So when the countdown is compelted you want to reload the page and then start the backup?

If not, then you don't need to refresh. Just have PHP say something like:

PHP Code:
if( $countdownMinutes == && $countdownSeconds == ){
     echo( 
"Backup Started!" );
     exit();

If you still want to do the refresh, see my previous post for the code.
__________________
Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
My posts, comments, code, and suggestions reflect only my personal views.
Web Portfolio and Code Snippets: http://shanechism.com
ShaneC is offline   Reply With Quote
Old 01-22-2011, 08:59 PM   PM User | #20
Dan13071992
Regular Coder

 
Join Date: Dec 2010
Location: Kent, UK
Posts: 573
Thanks: 23
Thanked 10 Times in 10 Posts
Dan13071992 is an unknown quantity at this point
in a way yes, sorry if i am confusing you, the only other way i can think of itt being done is if the box can be set to disappear from the page without a refresh, as it will be in a box like i have displayed?
Dan13071992 is offline   Reply With Quote
Old 01-22-2011, 09:01 PM   PM User | #21
ShaneC
Codeasaurus Rex


 
Join Date: Jun 2008
Location: Redmond, WA
Posts: 659
Thanks: 31
Thanked 100 Times in 94 Posts
ShaneC is on a distinguished road
Yeah, you can do that easily with jQuery.

Let's say your checkbox has an ID of "backupCheckbox".

Then in the $(document).ready( function() { ... } block use something like this:

Code:
$("#backupCheckbox").hide();
__________________
Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
My posts, comments, code, and suggestions reflect only my personal views.
Web Portfolio and Code Snippets: http://shanechism.com
ShaneC is offline   Reply With Quote
Old 01-22-2011, 09:02 PM   PM User | #22
Dan13071992
Regular Coder

 
Join Date: Dec 2010
Location: Kent, UK
Posts: 573
Thanks: 23
Thanked 10 Times in 10 Posts
Dan13071992 is an unknown quantity at this point
will that hide it when it gets to zero?
Dan13071992 is offline   Reply With Quote
Old 01-22-2011, 09:06 PM   PM User | #23
ShaneC
Codeasaurus Rex


 
Join Date: Jun 2008
Location: Redmond, WA
Posts: 659
Thanks: 31
Thanked 100 Times in 94 Posts
ShaneC is on a distinguished road
If you combine it with what I already suggested. I really don't want to do too much in the way of coding for you here. The point is that you need to learn, otherwise if this breaks down you'll have no way to fix it or even modify it.

In your jQuery AJAX you put a condition:

Code:
var refreshCountdown = 	setInterval( function() {
						$.get( "/ajaxTimer.php", {}, function( data ){
							if( data == "Database Backup in T-Minus 0 minutes 0 seconds!" )
								$("#backupCheckbox").hide();
							else
								$("#countdownBlock").html( data );
						});
					}, 1000 );
__________________
Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
My posts, comments, code, and suggestions reflect only my personal views.
Web Portfolio and Code Snippets: http://shanechism.com
ShaneC is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:34 AM.


Advertisement
Log in to turn off these ads.