【发布时间】:2011-06-09 15:50:02
【问题描述】:
我知道这是一个被广泛讨论的话题。但我遇到了一个我找不到答案的问题。我正在使用 AJAX 来加载提要。我知道它从 .xml 扩展名读取,但并非所有 rss 链接都以 .xml 结尾。
我知道有 google API,还有 rss2js 等,但我不能使用它,也不能使用 jQuery、prototype 之类的 javascript 库..
代码如下:
如果(窗口。XMLHttpRequest){ xmlhttp=新的 XMLHttpRequest(); } 别的 { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { 如果(xmlhttp.readyState==4 && xmlhttp.status==200){ //尚未添加代码来解析它... document.getElementById("myDiv").innerHTML=xmlhttp.responseXML; } } xmlhttp.open("GET","http://wordpress.org/support/rss/topic/how-to-get-xml-address-of-wordpress-rss-feed",true); xmlhttp.setRequestHeader('Connection','close'); xmlhttp.send(null);那篇博文不是我的,我也不想宣传它.. :) 在我寻找答案时发现了它,包括在内是为了让我的问题更容易解释..
当我在浏览器中输入该 url 时,它显示了一些帖子。但代码没有返回任何内容。还使用 firebug(firefox 扩展)的网络面板进行了检查,没有返回任何内容。 它不是我想要的 wordpress RSS(他们有一个 API),请考虑将其替换为任何其他提要 url..
我在那个代码中哪里出错了..?
【问题讨论】: