Results 1 to 4 of 4

Thread: Ajax refresh problem

  1. #1
    Join Date
    Sep 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Ajax refresh problem

    1) Script Title: Ajax XML Ticker (txt file source)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...ajaxticker.htm

    3) Describe problem:

    Hello Folks,

    I'm a newbie to Ajax, and just have a quick question. I'm using the Ajax XML Ticker above and it works great. However I would like to have the script go and fetch an update of the XML file at a given interval, say every five seconds and refresh the display with the new data. I have tried everything that I can think of, but cannot seem to get this to work.
    It would appear that I need to call this.getXMLfile() every so often, but I have not been successful.

    Any help or suggestions would be greatly appreciated.

    Thanks,
    Shawn

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    This is more of a feature request than problem. I may eventually add such an ability to the script; in the meantime, the best I can do is give you an idea of how to do this. Firstly, replace the original rotatemsg() function inside the script with the below instead:

    Code:
    ajax_ticker.prototype.rotatemsg=function(){
    var instanceOfTicker=this
    if (this.mouseoverBol==1) //if mouse is currently over ticker, do nothing (pause it)
    this.pausetimer=setTimeout(function(){instanceOfTicker.rotatemsg()}, 100)
    else{ //else, construct item, show and rotate it!
    this.fadetransition("reset") //FADE EFFECT- RESET OPACITY
    this.contentdiv.innerHTML=this.messages[this.pointer]
    this.fadetimer1=setInterval(function(){instanceOfTicker.fadetransition('up', 'fadetimer1')}, 100) //FADE EFFECT- PLAY IT
    this.pointer=(this.pointer<this.messages.length-1)? this.pointer+1 : 0
    this.rotatetimer=setTimeout(function(){instanceOfTicker.rotatemsg()}, this.delay) //update container periodically
    }
    }
    The parts in red are now, basically adding identifiers to the timers used by the function, to cancel them before refreshing the script. Then, for the script on your HTML page itself, you may have something like:
    Code:
    <script type="text/javascript">
    
    var xmlfile="tickercontent.txt" //path to ticker txt file on your server.
    
    //ajax_ticker(xmlfile, divId, divClass, delay, optionalfadeornot)
    var myticker=new ajax_ticker(xmlfile, "ajaxticker1", "someclass", 3500, "fade")
    </script>
    
    <script type="text/javascript">
    
    function updatesource(){
    clearTimeout(myticker.rotatetimer)
    clearTimeout(myticker.fadetimer1)
    clearTimeout(myticker.pausetimer)
    document.getElementById(myticker.tickerid).firstChild.innerHTML="refreshing contents..."
    myticker.getXMLfile()
    }
    
    //refresh ticker source every 4 seconds
    setInterval("updatesource()", 4000)
    
    </script>
    DD Admin

  3. #3
    Join Date
    Sep 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thank you so much

    Dear ddadmin,

    I appreciate you taking time out of your busy schedule to give me some great ideas to point me in the right direction. Unfortunately I'm under the gun and need some additional help with customization. I noticed that you have a forum for folks that are willing to pay for additional assistance. I will post what I need to have, and will also pay you for your time already spent as well as any other time needed if you could fit me in to your schedule. My deadline is late Wednesday evening on this one

    Thank you again, you are a lifesaver!!

    Shawn

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Hi Shawn:
    You're welcome, though due to my current very hectic schedule, I personally can't take on your paid request. Hopefully another senior member will be willing to take a stab at it. If you're really under a very tight timeline, you may also want to consider reposting your request on a dedicated freelancer type site such as Elance.com or Getafreelancer.com.

    Sorry for not being able to help you myself.
    DD Admin

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
  •