Solved

Ajax loading div with decrementing counter

Posted on 2011-03-04
7
386 Views
Last Modified: 2012-05-11
Hi,
I have already set up a loading div and I pass php based time to it.
what I looking for is a nice loading div with the decrementing counter - I can pass the counter/time to it

It would be great if some one could help me out with it.

Thanks,
Sameer.
0
Comment
Question by:SameerMirza
  • 4
  • 3
7 Comments
 
LVL 8

Expert Comment

by:McNetic
ID: 35081616
If you can provide a working code sample of what you already have, I'll try to help you find a solution. I don't exactly understand what you have, and what you want to get.
0
 

Author Comment

by:SameerMirza
ID: 35082880
its just be java script, AJAX and CSS I belive or may be only CSS.
I am sure you are aware of timer functions in javascript
lets say I have 60 secnods
All I want to show is display the counter 60, 59, 58....seconds remaining
Although I have changed my design but it would be goog to find a solution
I hope you understand what I want achieve
0
 
LVL 8

Accepted Solution

by:
McNetic earned 500 total points
ID: 35083079
That could be as simple as this:

<div id="counter">Counter
</div>
<script type="text/javascript">
function countdown(start) {
	if ('undefined' == typeof(start)) {
		start = parseInt(document.getElementById('counter').firstChild.data) - 1;
	}
	document.getElementById('counter').firstChild.data = start;
	if (0 < start) {
		setTimeout(countdown, 1000);
	}
}
countdown(60);
</script>

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:SameerMirza
ID: 35083859
thanks for your help. It would be done like this but I am not exactly what I am looking for.
for example we say setTimeout(countdown, 60000);
I am looking for a counter to be display as 60 - 59 - 58 untlil it reaches 0
mean 60 sec to 0 secs waiting div.
0
 
LVL 8

Expert Comment

by:McNetic
ID: 35086856
Uhm, I'm afraid we've got a little misunderstanding. What do you mean by waiting div? Did you try my code? It does display a div, starting with 60, counting down to 0, decrementing by 1 every second.
0
 

Author Comment

by:SameerMirza
ID: 35093333
hey it man :) my bad
0
 

Author Closing Comment

by:SameerMirza
ID: 35093336
it works :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Consume Rest Post API from Jquery Ajax 8 32
AJAX save form on click of a button. 7 32
Image Checkboxes 1 65
Mysqli_query() & Ajax 2 49
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…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 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

11 Experts available now in Live!

Get 1:1 Help Now