Solved

update value every hr using ajax and jquery

Posted on 2011-09-21
3
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
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 a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

756 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