•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 427,382 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,037 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1101 | Replies: 2
![]() |
•
•
Join Date: Jun 2006
Location: College Station, TX
Posts: 35
Reputation:
Rep Power: 3
Solved Threads: 0
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.
Thanks,
Gil
javascript Syntax (Toggle Plain Text)
<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
•
•
Join Date: Apr 2005
Location: New York state
Posts: 468
Reputation:
Rep Power: 5
Solved Threads: 71
It's not a Firefox bug its that you're only coding for IE. Use this to get your request object
Then just
javascript Syntax (Toggle Plain Text)
var XMLHttpFactories = [ function () {return new XMLHttpRequest()}, function () {return new ActiveXObject("Msxml2.XMLHTTP")}, function () {return new ActiveXObject("Msxml3.XMLHTTP")}, function () {return new ActiveXObject("Microsoft.XMLHTTP")} ]; function createXMLHTTPObject() { var xmlhttp = false; for (var i=0;i<XMLHttpFactories.length;i++) { try { xmlhttp = XMLHttpFactories[i](); } catch (e) { continue; } break; } return xmlhttp; }
javascript Syntax (Toggle Plain Text)
var xmlHttp = createXMLHTTPObject();
GCS d- s+:+ a-->? C++(++++) UL+++ P+>+++ L+++ !E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
age ajax api asp beta blogger blogging browser browsers chips code development dos echo enterprise firefox gdata google hardware ibm ibm. news intel ibm internet it linux memory microsoft mozilla news office open source openoffice php programming ps3 recession red hat remote working rss russia searchmonkey security software supercomputing testing trends web working x86 xml
- Previous Thread: collapse/expand table row
- Next Thread: Javascript Page Preloader-


Linear Mode