0

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?

enter image description here

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Stranger
  • 10,332
  • 18
  • 78
  • 115

3 Answers3

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