简体   繁体   English

Chrome中的MIME类型错误

[英]MIME type in Chrome error

When I load my web application in Chrome it shows the folliwing in the console log: 当我在Chrome中加载Web应用程序时,它在控制台日志中显示了错误:

Resource interpreted as Script but transferred with MIME type text/plain: 资源被解释为脚本,但以MIME类型text / plain传输:

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). 我认为这是我遇到的问题的原因(可以在控制台中正常使用的有效功能,但.js脚本文件中没有)。

I've read that the solution is to put your <script type= s to "application/javascript" . 我已经读过,解决方案是将您的<script type= s放入"application/javascript" I have tried this, but it failed. 我已经尝试过了,但是失败了。 Is there another solution? 还有其他解决方案吗?

theres an error with your server-sided code, the server sends "text/plain" when the browser expects "text/javascript" 您的服务器端代码存在错误,当浏览器期望“ text / javascript”时,服务器发送“ text / plain”

.. 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 ..如何解决此问题取决于您使用的服务器(lighthttpd / apache / nginx /等),但是..如果您有一些脚本语言(如PHP)(如今几乎所有的网络服务器都拥有这种语言),则可以使用该语言自定义MIME ..喜欢

jsstuff.js.php jsstuff.js.php

<?php header("content-type: text/javascript");?>
//javascript goes here!

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM