quot;Resource interpreted as script but transferred with MIME type text/html.quot;(“资源被解释为脚本,但以 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 是:
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 传输."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“资源被解释为脚本,但以 MIME 类型 text/html 传输."
基础教程推荐
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 直接将值设置为滑块 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01