简体   繁体   English

错误:MIME类型('application / json')无法执行,并且使用YQL语句启用了严格的MIME类型检查?

[英]Error: MIME type ('application/json') is not executable, and strict MIME type checking is enabled with YQL statements?

I was trying to run an example about YQL from Yahoo . 我试图从Yahoo运行一个有关YQL的示例。 This is the code that I am supposed to use: 这是我应该使用的代码:

<body>
<div id='results'></div>
<script src='https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%3D%22http%3A%2F%2Frss.news.yahoo.com%2Frss%2Ftopstories%22&format=json&diagnostics=true&callback='></script>
</body>
<script type='text/javascript'>
function top_stories(o){
  var items = o.query.results.item;
  var output = '';
  var no_items=items.length;
  for(var i=0;i<no_items;i++){
    var title = items[i].title;
    var link = items[i].link;
    var desc = items[i].description;
    output += "<h3><a href='" + link + "'>"+title+"</a></h3>" + desc + "<hr/>";
  }
  document.getElementById('results').innerHTML = output;  
}
</script>

I have read other question with same error and most of them give an answer similar to this one 我已经阅读了另一个具有相同错误的问题,其中大多数给出的答案与此相似

By adding a callback argument, you are telling jQuery that you want to make a request for JSONP using a script element instead of a request for JSON using XMLHttpRequest. 通过添加一个回调参数,您告诉jQuery您想使用脚本元素而不是使用XMLHttpRequest来请求JSONP来请求JSONP。 JSONP is not JSON. JSONP不是JSON。 It is a JavaScript program. 这是一个JavaScript程序。

My problem is I am using JavaScript and I can't find the code in above script where I am expecting JSONP. 我的问题是我正在使用JavaScript,但是在我期望JSONP的上述脚本中找不到代码。 I am a complete newbiw so may be I have made a silly mistake. 我是新手,所以我可能犯了一个愚蠢的错误。 What is wrong with the code above? 上面的代码有什么问题? Thanks. 谢谢。

The <script> element on line 3 is requesting the JSONP. 第3行的<script>元素正在请求JSONP。 It's just hard coded to do it instead of being added with JS (which would be normal for JSONP). 只是很难做到这一点,而不是使用JS添加(对于JSONP来说是正常的)。

YQL is delivering JSON because you've said callback= and then stopped without actually providing a callback function name. YQL正在传递JSON,因为您已经说过callback= ,然后在没有实际提供回调函数名称的情况下停止了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MIME 类型 ('application/json') 不可执行,并且启用了严格的 MIME 类型检查 - MIME type ('application/json') is not executable, and strict MIME type checking is enabled 拒绝执行脚本,因为它的 MIME 类型 ('application/gzip') 不可执行,并且启用了严格的 MIME 类型检查 - Refused to execute script because its MIME type ('application/gzip') is not executable, and strict MIME type checking is enabled javascript:MIME类型(&#39;text / html&#39;)无法执行,并且启用了严格的MIME类型检查 - javascript: MIME type ('text/html') is not executable, and strict MIME type checking is enabled Angular 6:拒绝从“URL”执行脚本,因为它的 MIME 类型()不可执行,并且启用了严格的 MIME 类型检查 - Angular 6 : Refused to execute script from 'URL' because its MIME type( ) is not executable, & strict MIME type checking is enabled 拒绝执行脚本,因为 MIME 类型('text/html')不可执行,并且启用了严格的 MIME 类型检查 - Refused to execute script because MIME type ('text/html') is not executable, and strict MIME type checking is enabled GeoJSON 文件:拒绝执行脚本,因为其 MIME 类型 (&#39;&#39;) 不可执行,并且启用了严格的 MIME 类型检查 - GeoJSON file: Refused to execute script from because its MIME type ('') is not executable, and strict MIME type checking is enabled Dropbox:MIME 类型 (&#39;text/html&#39;) 不可执行,并且启用了严格的 MIME 类型 &gt; 检查 - Dropbox: MIME type ('text/html') is not executable, and strict MIME type > checking is enabled 启用了严格的 mime 类型检查,拒绝执行来自 ' 的脚本<url> ' 它的 mime 类型 ('text/plain') 是不可执行的,并且</url> - strict mime type checking is enabled, refused to execute script from '<url>' its mime type ('text/plain') is not executable, and MIME类型(&#39;application / json&#39;)不可执行 - MIME type ('application/json') is not executable 拒绝从&#39;*&#39;执行脚本,因为它的MIME类型(&#39;application / json&#39;)不可执行,并且严格的MIME类型为che - getting Refused to execute script from '*' because its MIME type ('application/json') is not executable, and strict MIME type che
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM