Home  >  Article  >  php教程  >  IE下使用ajaxreturn返回JSON数据提示下载的问题

IE下使用ajaxreturn返回JSON数据提示下载的问题

WBOY
WBOYOriginal
2016-06-07 11:44:421276browse

thinkphp新版设置了ajaxreturn方法如果是JSON格式会自动设置头信息为JSON格式,这样做在谷歌下可以正常解析,但是在IE和OPERA浏览器下就会提示下载,从而导致程序出错,修改方法如下
thinkphp新版设置了ajaxreturn方法如果是JSON格式会自动设置头信息为JSON格式,这样做在谷歌下可以正常解析,但是在IE和OPERA浏览器下就会提示下载,从而导致程序出错,修改方法如下
打开:ThinkPHP/Lib/Core/Action.class.php
查找到代码:header('Content-Type:application/json; charset=utf-8');修改为:header('Content-Type:text/html; charset=utf-8');总共有两处。
另外,建议官方不要多此一举,text/html所有浏览器都支持,而application/json只有新型浏览器支持,会造成很多不必要的麻烦,[兼容很重要]。

附件 QQ截图20130528152452.png ( 21.83 KB 下载:180 次 )

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn