简体   繁体   English

Chrome上出现AJAX错误消息,启用了MIME类型检查

[英]AJAX error message on Chrome, MIME type checking is enabled

Every time I run this code I get this error message: 每次我运行此代码时,都会收到以下错误消息:

index.html:1 Refused to execute script from ' http://quotesondesign.com/wp-json/posts?callback=jQuery321021689358047216856_1511579115978 ' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled. index.html:1拒绝从' http://quotesondesign.com/wp-json/posts?callback=jQuery321021689358047216856_1511579115978 '执行脚本,因为其MIME类型('application / json')无法执行,并且严格的MIME类型检查是启用。

$.ajax({
    url: "http://quotesondesign.com/wp-json/posts",
    type: "GET",
    dataType: 'jsonp',
    cache: true,
    success: function (data, status, error) {
        console.log('success', data);
    }
}); 

I cant find a solution, please help me resolve this bug. 我找不到解决方案,请帮助我解决此错误。

You are telling jQuery to read it as JSONP. 您正在告诉jQuery将其读取为JSONP。

JSON and JSONP are different. JSON和JSONP不同。

You need to either change the server to respond with JSONP or change the JavaScript to expect JSON. 您需要更改服务器以使用JSONP进行响应,或者更改JavaScript以使用JSONP。

If you change the client to expect JSON, then you also need to change the server (quotesondesign.com) to provide the CORS headers that give the browser permission to ignore the Same Origin Policy. 如果更改客户端以使用JSON,则还需要更改服务器(quotesondesign.com)以提供CORS标头,该标头赋予浏览器忽略相同原点策略的权限。

暂无
暂无

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

相关问题 错误:MIME类型(&#39;application / json&#39;)无法执行,并且使用YQL语句启用了严格的MIME类型检查? - Error: MIME type ('application/json') is not executable, and strict MIME type checking is enabled with YQL statements? MIME 类型 ('application/json') 不可执行,并且启用了严格的 MIME 类型检查 - MIME type ('application/json') is not executable, and strict MIME type checking is enabled Chrome中的MIME类型错误 - MIME type in Chrome error 禁用 Chrome 严格的 MIME 类型检查 - Disable Chrome strict MIME type checking 拒绝执行脚本并启用严格的 MIME 类型检查 - Refused to execute script and strict MIME type checking is enabled 拒绝执行脚本,是否启用了严格的 MIME 类型检查? - Refused to execute script, 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 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 类型 ('application/gzip') 不可执行,并且启用了严格的 MIME 类型检查 - Refused to execute script because its MIME type ('application/gzip') is not executable, and strict MIME type checking is enabled
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM