[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

update value every hr using ajax and jquery

Posted on 2011-09-21
3
Medium Priority
?
289 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:
Gurvinder Pal Singh earned 2000 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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

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…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
Suggested Courses

834 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