I am trying to use ajax to display an rss feed. It works fine in IE, but does not work in firefox. Researching, I have heard that firefox has an error that occurs on an asynchronous ajax call. Does anyone know a work around for firefox. Any help much appreciated.
<body>
<script language="javascript" type="text/javascript">
var xmlHttp;
try
{
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("No AJAX support!");
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
var rss_response=xmlHttp.responseText;
try
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(rss_response);
}
catch(e)
{
try
{
parser=new DOMParser();
xmlDoc=parser.parseFromString(rss_response,"text/xml");
}
catch(e)
{
alert(e.message);
}
}
for (loop=1; loop<=10; loop++)
{
document.write("<p><a href=\"" + xmlDoc.getElementsByTagName("link")[loop].childNodes[0].nodeValue + "\">")
document.write(xmlDoc.getElementsByTagName("title")[loop].childNodes[0].nodeValue)
document.writeln("</a><br>");
document.writeln(xmlDoc.getElementsByTagName("description")[loop].childNodes[0].nodeValue + "</p>");
}
}
}
var url = "http://www.kbtx.com/home/headlines/index.rss"
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
</script>
</body>
Thanks,
Gil