Ajax Talk - Asynchronous javascript and xml discussion board
 FAQ   Search    Usergroups      Register   Profile   Check your messages   Log in 
Signup now to enjoy a range of free membership advantages !!
Ajax Talk - Moderators Wanted
RSS Feed 'Sticks' on timeout

 
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help
View previous topic :: View next topic  
Author Message
gjgbarclay
New one
New one


Joined: 09 Oct 2008
Posts: 1

PostPosted: Thu Oct 09, 2008 10:14 am    Post subject: RSS Feed 'Sticks' on timeout Reply with quote

Hi,

First of all I'm far from a javascript/ajax/html expert so go easy.

I've been given the code below to get an RSS feed and dynamically update it on an html page, (currently set to every 10 seconds for testing).

What happens most times is that the RSS feeds stops scrolling through items (set to every 1 second, again for testing) after the xmlHttp timeout (10sec).

Occasionally the RSS will continue scrolling through items as desired, but once there is an update to rss.xml, the update will be shown then the feed will stick.

Any suggestions or changes to code would be appreciated.

Javascript:

window.onload = init;

var xmlHttp
var x = 2;

function init(){

getXML();
setTimeout("updateView()", 2000);

}


function getXML()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="rss.xml";
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
setTimeout("getXML()",10000);
}



function updateView(){
var temp = xmlHttp.responseXML.documentElement;
var y = temp.getElementsByTagName("title")[x].childNodes[0].nodeValue;
var truncateDescription = temp.getElementsByTagName("description")[x-1].childNodes[0].nodeValue;
if(truncateDescription.length > 170){
truncateDescription = truncateDescription.substr(0, 170);
truncateDescription = truncateDescription.concat("...");
var date = temp.getElementsByTagName("pubDate")[x-2].childNodes[0].nodeValue;

}


document.getElementById("txthint").innerHTML=y;
document.getElementById("txthint2").innerHTML=truncateDescription;
document.getElementById("txthint3").innerHTML=date;


x = x+1;
if(x > 7){
x = 2;
}

setTimeout("updateView()",1000);
}

function GetXmlHttpObject()
{
var xmlHttpReq;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttpReq=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttpReq;
}


HTML

<p>
<div style="color:0091b8" id="txthint">Your Items for sale</div>
<div style="color:gray;font-size=60%" id="txthint3">Will be listed here</div>
<div style="font-size=85%; color:black" id="txthint2">Spell things correctly</div>
</p>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
 Advertisements
 XML & Copyright Notice 
    


Powered by phpBB © 2001, 2005 phpBB Group

What is according to Wikipedia: Ajax Web2.0 XML E4X


Link to our site:

  


del.icio.us digg spurl wists simpy newsvine blinklist furl blogmarks yahoo! myweb smarking ma.gnolia segnalo reddit fark technorati cosmos


Normal Bookmark


Partner Button Links:
Codecrunch.com: Webmaster Tutorials    One Ajax


Partner Text Links:
quomon | web20log | ajaxmatters | tableless | 456bereastreet | music charts | gift ideas | competitions | free xbox 360 | link trade ?


Credits:
it consultancy & project management lead generation zoekmachine optimalisatie steal these buttons seo expert