Show live updated data on website

Discussion in 'Programming/Scripts' started by edge, Aug 27, 2010.

  1. edge

    edge Active Member Moderator

    One of my small website projects requires weather data to be updated every 60 seconds on a webpage.

    I know I can do this with a page refresh / iframe, but I do not want to it this way.

    Is there any other way of geting this done? Jquery, Ajax, Flash???
    The weather data is posted in a XML and TXT file.
     
  2. damir

    damir New Member

    Have you tried running the file through cron?
     
  3. edge

    edge Active Member Moderator

    Let me try to explain.

    I have a static webpage (index.html), and on this I want to update data every 60 seconds.
    The person looking at the page needs to see this updated data, but without him needing to refresh the page, or refreshing the page with a "<meta http-equiv="Refresh" content="60;URL=" />"
     
    Last edited: Aug 27, 2010
  4. damir

    damir New Member

    Ok, you have static page and in the static page you are importing and presenting data throught XML or Text file.

    I have used following script in one of my projects where i needed to refresh content of a .php file inside a div.

    Code:
    <html>
    <head>
    <script src=/path/to/jquery.js"></script>
    <script>
     $(document).ready(function() {
     	 $("#refreshcontainer").load("refresh.php");
       var refreshId = setInterval(function() {
    	  $("#refreshcontainer").load('refresh.php?randval='+ Math.random());
       }, 9000);
    });
    </script>
    </head>
    <body>
     
    <div id="refreshcontainer">
    </div>
    </body>
     
  5. edge

    edge Active Member Moderator

    That looks usable :)

    I'm going to give it a go, and will report back.

    Thank you.
     

Share This Page