Results 1 to 1 of 1

Thread: Dynamic Ajax Content refresh intervals?

  1. #1
    Join Date
    Feb 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Dynamic Ajax Content refresh intervals?

    Script: Dynamic Ajax Content
    http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    Here's the scenario:
    I have a page that loads a band's setlist live as it is played. Currently I have index.php that has a php include to bring in the setlist onto my index.php page. The index.php reloads with a javascript page reloader every 60 seconds to update the current setlist. This works great, but of course I've noticed how cool it would be to reload only the setlist with AJAX so that the whole screen doesn't reload, only the setlist would reload.

    I have successfully implemented this script to get the setlist on my index.php when the page loads, but I still don't have an AJAX way to reload the setlist without reloading the whole window. How can I make this AJAX function reload the setlist every 60 seconds? Basically I just need a 60 second reload timer on this AJAX script but my javascript is lacking skill I'm not sure how to do it.

    I have included the script that I use to reload the page here. It displays a count down from 60 until the page refreshes. If possible I was thinking instead of the script doing a window.location.reload(), it could simply reload my Dynamic AJAX Content script, but how?
    Here it is:
    Code:
    <script language="JavaScript">
    var countDownInterval=60;
    var countDownTime=countDownInterval+1;
    function countDown(){
    countDownTime--;
    if (countDownTime <=0){
    countDownTime=countDownInterval;
    clearTimeout(counter)
    window.location.reload()
    return
    }
    if (document.all) //if IE 4+
    document.all.countDownText.innerText = countDownTime+" ";
    else if (document.getElementById) //else if NS6+
    document.getElementById("countDownText").innerHTML=countDownTime+" "
    else if (document.layers){ //CHANGE TEXT BELOW TO YOUR OWN
    document.c_reload.document.c_reload2.document.write('Next reload is in <b id="countDownText">'+countDownTime+' </b> seconds')
    document.c_reload.document.c_reload2.document.close()
    }
    counter=setTimeout("countDown()", 1000);
    }
    
    function startit(){
    if (document.all||document.getElementById) //CHANGE TEXT BELOW TO YOUR OWN
    document.write('Next reload is in <b id="countDownText">'+countDownTime+' </b> seconds')
    countDown()
    }
    
    if (document.all||document.getElementById)
    startit()
    else
    window.onload=startit
    
                  </script>
    Thanks for anyone's help,
    Jeff
    Last edited by jeff; 02-02-2006 at 09:01 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •