使用jquery(跨域)从Feed中读取新闻,获取未捕获的SyntaxError:意外的令牌<错误

Ris*_*ati 0 javascript ajax jquery xmlhttprequest cors

我正在尝试从SharePoint网站及其跨域访问中读取yahoo新闻提要。我正在使用提到的代码进行访问,但是遇到以下错误,我走过许多站点和博客,但仍然没有运气。(我正在Chrome控制台中运行此代码)

未捕获到的SyntaxError:意外令牌<

$.ajax({
  type:"GET",
  url:"https://www.yahoo.com/news/rss/world",
  dataType: "jsonp",
  success: function(data){
    console.log(data);
  }
});
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

请提出建议!

sel*_*mas 6

Google API Feed已被弃用。因此,请尝试使用rss2json网站之类的替代方法来读取转换为json的rss。

http://rss2json.com/
Run Code Online (Sandbox Code Playgroud)

例:

将您的rss网址如下所示

url: "https://api.rss2json.com/v1/api.json?rss_url=" + "https://www.yahoo.com/news/rss/world",
Run Code Online (Sandbox Code Playgroud)

var url= 'https://www.yahoo.com/news/rss/world';
$.ajax({
  type: 'GET',
  url: "https://api.rss2json.com/v1/api.json?rss_url=" + url,
  dataType: 'jsonp',
  success: function(data) {
    console.log(data.feed.description);    
    console.log(data);
  }
});
Run Code Online (Sandbox Code Playgroud)

这是工作中的jsfiddle:http : //jsfiddle.net/yvzSL/1406/

我认为这应该对您有帮助