Chrome中出现MIME类型错误 [英] MIME type in Chrome error
问题描述
当我在Chrome中加载我的Web应用程序时,它会在控制台日志中显示以下内容:
When I load my web application in Chrome it shows the folliwing in the console log:
资源解释为脚本,但通过MIME传输类型text / plain:
Resource interpreted as Script but transferred with MIME type text/plain:
我认为这是我一直存在的问题的原因(完全有效的函数在控制台,但不在.js脚本文件中)。
I think this is the cause of the problems I've been having (perfectly valid functions that work in the console, but not in the .js script files).
我读过解决方案是将< script type =
s到application / javascript
。我已经尝试过,但失败了。是否有另一种解决方案?
I've read that the solution is to put your <script type=
s to "application/javascript"
. I have tried this, but it failed. Is there another solution?
推荐答案
Theres与服务器端代码错误,服务器发送text / plain浏览器期望文本/ JavaScript
theres an error with your server-sided code, the server sends "text/plain" when the browser expects "text/javascript"
..如何解决这个问题取决于你使用的服务器(lighthttpd / apache / nginx / etc),但是..如果你有一些像PHP这样的脚本语言(几乎所有的Web服务器都有这些日子),您可以使用它来自定义MIME ..就像
.. how to fix this depends on what server you use (lighthttpd / apache / nginx / etc) , but.. if you have some scripting language like PHP (which nearly all webservers has these days) , you can use that to customize the MIME.. like
jsstuff.js.php
jsstuff.js.php
<?php header("content-type: text/javascript");?>
//javascript goes here!
这篇关于Chrome中出现MIME类型错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!