我正在向服务器发送一些数据并以 JSON 格式接收响应。它按预期在 Mozilla 和 chrome 中工作。但在 IE 中,它要求下载文件,而不是正确解析 JSON。有没有什么办法解决这一问题?
问问题
1563 次
3 回答
0
尝试在响应中指定text/plain
或的 MIME 类型。或者只是从 url 中application/json
删除扩展名(例如尝试,或)。.json
.txt
.js
于 2012-09-30T03:04:54.973 回答
0
我总是把这段代码输出 JSON 并且缓存没有问题,特别是在 IE 中
// Expire immediately
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
//Content type
header("Content-type: application/json");
print json_encode($output);
于 2012-09-30T10:20:11.590 回答
-1
服务器可能会使用“application/json”mime 类型来回答。尝试将其更改为“文本/纯文本”。
于 2012-09-30T03:05:21.230 回答