Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

update value every hr using ajax and jquery

Posted on 2011-09-21
3
Medium Priority
?
287 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:
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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.
This article discusses how to implement server side field validation and display customized error messages to the client.
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 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

618 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