Resource interpreted as Script but transferred with MIME type text/html
2014-03-05 11:06
531 查看
在开发的一个项目中有用PHP生成JS代码的功能,程序在引用的时候一切正常。但是在Chrome浏览器里显示:"Resource interpreted as Script but transferred with MIME type text/html: ….. "。
这是由于服务器端给你发回的http响应的content-type值是text/plain(默认)而你所期望返回的是兼容javascript类型的。所以浏览器提示上面的警告信息。
解决方法,可以在服务器端的返回字段里增加:Content-type:application/x-javascript。由于我使用的是PHP所以在代码前面使用header输出:
PHP里设置MIME:
<?php header('Content-type: application/x-javascript'); ?>
用script做ajax跨域,请求返回的是个文本字符串,chrome提示:
Resource interpreted as Script but transferred with MIME type text/html.
(请求的是script文件,返回的却是个文本格式)
貌视chrome浏览器比较认这个格式~,去掉<!DOCTYPE html>就行了。
这是由于服务器端给你发回的http响应的content-type值是text/plain(默认)而你所期望返回的是兼容javascript类型的。所以浏览器提示上面的警告信息。
解决方法,可以在服务器端的返回字段里增加:Content-type:application/x-javascript。由于我使用的是PHP所以在代码前面使用header输出:
PHP里设置MIME:
<?php header('Content-type: application/x-javascript'); ?>
用script做ajax跨域,请求返回的是个文本字符串,chrome提示:
Resource interpreted as Script but transferred with MIME type text/html.
(请求的是script文件,返回的却是个文本格式)
貌视chrome浏览器比较认这个格式~,去掉<!DOCTYPE html>就行了。
相关文章推荐
- 关于chrome Resource interpreted as Script but transferred with MIME type text/html的问题
- 关于chrome Resource interpreted as Script but transferred with MIME type text/html的问题
- web——css和图片突然加载不了,console报错:Resource interpreted as script but transferred with MIME type text/html.
- Resource interpreted as Script but transferred with MIME type text/plain:
- golange 错误如下 Resource interpreted as Script but transferred with MIME type text
- Chrome 报 Resource interpreted as Script but transferred with MIME type text/plain 警告的解决办法
- Resource interpreted as Stylesheet but transferred with MIME type text/html:以及Uncaught SyntaxError:
- Chrome 报 Resource interpreted as Script but transferred with MIME type text/plain 警告的解决办法
- 关于 Resource interpreted as Script but transferred with MIME type text/plain问题的处理
- Java过滤器引发的异常:Resource interpreted as Stylesheet but transferred with MIME type text/html
- Resource interpreted as Script but transferred with MIME type text/plain
- Chrome 报 Resource interpreted as Script but transferred with MIME type text/plain 警告的解决办法
- Resource interpreted as Stylesheet but transferred with MIME type text/plain
- Resource interpreted as Image but transferred with MIME type text/plain 警告解决方案
- web页面 显示 Resource interpreted as Stylesheet but transferred with MIME type text/plain的错误警告
- 建站记录2-CSS文件未加载-已解决-Resource interpreted as Stylesheet but transferred with MIME type text/plain
- Resource interpreted as Stylesheet but transferred with MIME type text/plain
- Resource interpreted as Document but transferred with MIME type application/json ...
- Resource interpreted as Document but transferred with MIME type application/json ...
- Resource interpreted as Stylesheet but transferred with MIME type application/x-css