Solved

update value every hr using ajax and jquery

Posted on 2011-09-21
3
278 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
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…

746 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

17 Experts available now in Live!

Get 1:1 Help Now