Solved

update value every hr using ajax and jquery

Posted on 2011-09-21
3
279 Views
Last Modified: 2012-05-12
how to update the value inside a span every hour using ajax and jquery.
please provide an example.

<html>
<head></head>
<body>

<span id="stockvalue">12.23</span>

</body>
</html>
0
Comment
Question by:jcbmtt
3 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 36572389
make an ajax call after every one hour

setTimeout("fetchContent()", 60*60*1000); //milliseconds

and set the data to this id inside the success handler here
http://api.jquery.com/jQuery.get/

$("#stockvalue").html("new value");
0
 
LVL 25

Expert Comment

by:Luis Pérez
ID: 36572392
<script type="text/javascript">
    function everyHour() {
        //do what you want to do (in this case, update span value)
        document.getElementByID('spanID').innerHTML = 'the new value';
        //program for the next hour
        window.setTimeout('everyHour()', 3600000);
    }
</script>

Hope that helps.
0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36573287
setInterval(function(){
    //code goes here that will be run every 1 hour  
}, 3600000);
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
Error in JQuery 5 37
Polygon I google maps 1 14
How to change pointer icon to hand icon on mouseover 2 18
what is the difference between a object and a array 4 25
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

911 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

24 Experts available now in Live!

Get 1:1 Help Now