ThinkPHP Resource interpreted as Document but transferred with MIME type application/json 导致js无效

来源:互联网 发布:移动网络切换器 编辑:程序博客网 时间:2024/06/05 17:34

ThinkPHP中当使用

$this->ajaxReturn(array('file'=>$outputFileName));

返回数据时header标签会被强行改成Content-Type:application/json; charset=utf-8;即使在之前你设置header(‘Content-Type:text/html; charset=utf-8’);也不行。如果你的请求数据类型和返回数据类型不同就会出现错误:
这里写图片描述

Resource interpreted as Document but transferred with MIME type application/json

后续js无法执行。

解决办法:
可使用一下方法解决:

header('Content-Type:text/html; charset=utf-8');echo json_encode($data);

这里写图片描述

1 0
原创粉丝点击