禁用Chrome严格的MIME类型检查
Is there any way to disable strict MIME type checking
in Chrome.
在Chrome中是否有办法禁用严格的MIME类型检查。
Actually I'm making a JSONP request on cross domain. Its working fine on Firefox but, while using chrome its giving some error in console.
实际上,我在跨域上发出一个JSONP请求。它在Firefox上运行良好,但是在使用chrome时在控制台出现了一些错误。
Refused to execute script from 'https://example.com' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
拒绝从“https://example.com”执行脚本,因为它的MIME类型(“text/plain”)不是可执行的,并且启用了严格的MIME类型检查。
Its working perfectly in Mozilla.. Issue is arising in chrome only
它在Mozilla非常好用。问题只在chrome中出现
Here are the response Headers of the request..
这是请求的响应头。
Cache-Control:no-cache, no-store
Connection:Keep-Alive
Content-Length:29303
Content-Type:text/plain;charset=ISO-8859-1
Date: xxxx
Expires:-1
Keep-Alive:timeout=5
max-age:Thu, 01 Jan 1970 00:00:00 GMT
pragma:no-cache
Set-Cookie:xxxx
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options:nosniff
X-Frame-Options:SAMEORIGIN
Workaround what i think : Externally setting content-type to application/javascript
解决我的想法:外部设置应用程序/javascript的内容类型
4 个解决方案
#1
8
The server should respond with the correct MIME Type for JSONP application/javascript
and your request should tell jQuery you are loading JSONP dataType: 'jsonp'
服务器应该响应JSONP应用程序/javascript的正确MIME类型,您的请求应该告诉jQuery您正在加载JSONP数据类型:“JSONP”
Please see this answer for further details ! You can also have a look a this one as it explains why loading .js
file with text/plain
won't work.
详情请参阅此答案!你也可以看看这个,因为它解释了为什么用文本/纯文本加载.js文件行不通。
更多相关文章
- 请问解决整数,货币,INT,DOUBLE,等类型的JavaScript验证--不是高手不
- 【第2篇】TypeScript - 基本类型详解
- 如果外部应用程序更改了持久模型(服务器数据库),AngularJS可以自
- python数据类型二(列表和元组)
- 流畅python学习笔记:第十二章:子类化内置类型
- 在两台服务器上有效地在两个Django应用程序之间进行通信(多租户)
- 如何停止Py_Initialise应用程序的崩溃?
- 在Python中强制使用函数参数类型?
- python常用数据类型-字典