I am sending some data to the server and receiving the response as JSON. It is working in mozilla and chrome as expected. But In IE it is asking to download the file, instead parsing the JSON properly. Is there any way to fix this?
Asked
Active
Viewed 1,705 times
0
-
Where you request the JSON data – Sidharth Mudgal Sep 30 '12 at 02:47
-
possible duplicate of [Json response download in IE(7~10)](http://stackoverflow.com/questions/13943439/json-response-download-in-ie710) – Joe Apr 25 '13 at 15:41
3 Answers
0
try specifying a MIME type of text/plain
or application/json
in the response. or just drop the .json
extension from the url (try .txt
, or .js
, for instance).

flavian
- 28,161
- 11
- 65
- 105
0
I always put this code to output JSON and have no problems with cache, specially in 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);

m4t1t0
- 5,669
- 3
- 22
- 30
-1
The server probably answers with "application/json" mime type. Try changing it to "text/plain".
Also: How can I convince IE to simply display application/json rather than offer to download it?

Community
- 1
- 1

Sergey Eremin
- 10,994
- 2
- 38
- 44