Reading RSS feed with jQuery?

后端 未结 2 1409
暖寄归人
暖寄归人 2021-02-03 12:58

Using the jQuery rss pluging jFeed, and using their example code on their website, I have created the following code which does not seem to work:

jQuery.getFeed(         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-03 13:37

    Your failing because of the same origin policy of JavaScript, which basically restricts you in the locations you can retrieve and manipulate files from.

    In general you can't retrieve content (in your case an rss feed) from locations different than the current page. Exceptions are just images and scripts.

    So one solution in your case may be to set up a proxy script on your server, which just calls the RSS feed and relays the results to your page. That way from the browser's perspective all content comes from the same origin.

提交回复
热议问题