开发者

Issues in Getting RSS/ATOM using javascript

开发者 https://www.devze.com 2023-02-05 01:37 出处:网络
I know this is a much discussed topic.. But I am facing an issue I am not finding answer to.. I am using AJAX to load the feed. I know it reads from the .xml extension, but not all rss links end in .x

I know this is a much discussed topic.. But I am facing an issue I am not finding answer to.. I am using AJAX to load the feed. I know it reads from the .xml extension, but not all rss links end in .xml.

I know there is google API, also rss2js etc, but I am not allowed to use it, nor can I use a javascript library like jQuery, prototype..

here is the code:

if (window.XMLHttpRequest){
    xmlhttp=new XMLHttpRequest();
} else {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200){
    //yet to add code to parse it...
    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);

that blog post is not mine, neither do I wish to advertise it.. :) found it while I was searching for the answer, included to make my problem more explanatory..

When I enter that url in the browser, it shows me some posts.. But the code returns nothing.. Also checked using the net panel of firebug(firefox extension), nothing returned. Its not wordpress RSS I want(they have an API), consider it replaced with any other feed url..

Where am I going w开发者_JAVA技巧rong in that code..?


You're attempting to read data from another domain name to the one your script is hosted on, which is forbidden by most browsers for security reasons.

There are a few workarounds for this limitation, but they're not especially straightforward.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号