“资源被解释为脚本,但是使用MIME类型text / html进行传输。” [英] "Resource interpreted as script but transferred with MIME type text/html."

查看:1150
本文介绍了“资源被解释为脚本,但是使用MIME类型text / html进行传输。”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,如果这是实际重复,但我没有设法找到我的问题的答案。

Sorry if this is actual duplicate but I haven't managed to find answer for my problem.

我使用jQuery的$ .getScript加载脚本。但它会导致以下错误:

I load the script with jQuery's $.getScript. But it causes the following error:


资源被解释为脚本但使用MIME类型text / html传输。

Resource interpreted as script but transferred with MIME type text/html.

此问题仅出现在Mac OS下的Safari中

The problem appears only in Safari under Mac OS

如果要查看从服务器收到的标题,包含 Content-Type:application / x-javascript ,所以我真的不明白这是什么问题。

If to look on headers received from the server, they contain Content-Type:application/x-javascript, so I really don't understand what the problem is.

推荐答案


资源被解释为脚本但以MIME类型text / html传输。

Resource interpreted as script but transferred with MIME type text/html.

从技术上讲,这不是错误,而是通知/警告,不应特别引起任何问题;如果有的话,这是一个很好的迹象,有些浏览器可能会选择忽略这样的回复。

Technically that's not an error but a notice / warning and should not cause any issues in particular; if anything it's a good indication that some browsers may choose to ignore such a response.

正确的 Content-Type 根据 RFC ,JavaScript的响应标头是:

The correct Content-Type response header for JavaScript according to the RFC is:

Content-Type: application/javascript

以前的 text / javascript application / x-javascript 的值分别已过时或已弃用;那说,IE< = 8只接受前者,所以在对你的文件进行任何修改时要小心。

Previous values of text/javascript and application/x-javascript are either obsolete or deprecated respectively; that said, IE <= 8 will only accept the former so be careful when making any changes to your documents.

这篇关于“资源被解释为脚本,但是使用MIME类型text / html进行传输。”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆