PDA

View Full Version : Advanced RSS Ticker (Ajax invocation)



jkepler
01-13-2016, 10:54 PM
Good evening,

I have a question about the great script "Advanced RSS Ticker (Ajax invocation)".

Sometimes, the request fetch to the RSS news fails (server down, delayed answer, etc).

I was able to handle the error message without a problem (I've made a simple "Please wait"...)

My question is: how do I repeat the request after 60 seconds - for instance - until the request is sucessfull?

I've tryed some javascript functions like set interval, etc. But I'm not geting any results... The repeating results appears in a new fresh blank window.

Any ideas?

Cheers,

JKepler

ddadmin
01-14-2016, 04:50 AM
Warning: Please include a link to the DD script in question in your post, in this case, . See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question.

Try modifying the below code of code inside the .js file:



rssticker_ajax.prototype.initialize=function(){
if (this.ajaxobj.readyState == 4){ //if request of file completed
if (this.ajaxobj.status==200){ //if request was successful
var xmldata=this.ajaxobj.responseXML
if(xmldata.getElementsByTagName("item").length==0){ //if no <item> elements found in returned content
document.getElementById(this.tickerid).innerHTML="<b>Error</b> fetching remote RSS feed!<br />"+this.ajaxobj.responseText
return
}

with the additions in red:



rssticker_ajax.prototype.initialize=function(){
if (this.ajaxobj.readyState == 4){ //if request of file completed
if (this.ajaxobj.status==200){ //if request was successful
var xmldata=this.ajaxobj.responseXML
if(xmldata.getElementsByTagName("item").length==0){ //if no <item> elements found in returned content
document.getElementById(this.tickerid).innerHTML="<b>Error</b> fetching remote RSS feed!<br />"+this.ajaxobj.responseText
var thisinst = this
setTimeout(function(){
thisinst.initialize()
}, 60000)
return
}

I haven't tested the above changes myself, but it should work. While testing, you may want to change 60000 (60 seconds delay) to a smaller number, like 6000 (6 seconds).

jkepler
01-15-2016, 08:47 AM
Hi,

I've made some tests...It seems it doesn't work if we call multiple rss feeders. I've changed one url in the bridge.php (for the wrong one) and then in the process uploaded the right one. The feed doesn't update...

Cheers,

JKepler

ddadmin
01-15-2016, 08:28 PM
Hmm how are you switching from the wrong URL to the correct one "mid flight"? With the changes I proposed above, it only works whereby a single URL that couldn't be fetched or is broken suddenly works after another attempt at fetching it.