0

I am having a problem in displaying json response using ajax in internet explorer. The other browsers displaying it correctly. But in internet explorer it is displayed as ??????.

Response Header is

Key Value
Response    HTTP/1.1 200 OK
Server  Apache-Coyote/1.1
Pragma  no-cache
Cache-Control   private, max-age=0, no-store, no-cache
Expires Fri, 22 Jan 2016 03:50:17 GMT
Cache-Control   no-cache, no-store, max-age=0, must-revalidate
Pragma  no-cache
Expires 0
X-XSS-Protection    1; mode=block
X-Frame-Options SAMEORIGIN
X-Content-Type-Options  nosniff
Content-Type    text/html;charset=UTF-8
Content-Length  145
Date    Fri, 22 Jan 2016 03:50:17 GMT

But in Internet Explorer Response body is given as

 {"data":null,"status":2,"message":"Request succeeded","errors":{"data1":"??????????????","data2":"??????????????"}}

In all other browsers it is displayed correctly

Akhil Sudhakaran
  • 357
  • 2
  • 3
  • 12
  • 1
    The browser doesn't control the response body. Sounds like you have a server issue. –  Jan 22 '16 at 04:06
  • There must be something missing in the `request body` which is not expected by your server side logic and it responds that way. – Rayon Jan 22 '16 at 04:07
  • It is working well in all other browsers. In response body also getting message in the desired format in those browsers. I am trying to display japanese message. But in response header I am setting charset as UTF-8 – Akhil Sudhakaran Jan 22 '16 at 04:09
  • @OP, Is there any way one could reproduce this issue ? If yes, kindly provide the same.. – Rayon Jan 22 '16 at 04:13

1 Answers1

1

I have found answer for that. Its a problem in server. We have to set response content type as text/plain in server. Following is my code that fixed my issue.

   @RequestMapping(value = "/uploading", method = RequestMethod.POST, produces = "text/plain;charset=UTF-8")
public @ResponseBody
String upload(@RequestParam(value = "file", required = false) MultipartFile file, Locale locale) {
//opertions here
return jsonSerializer.serialize(message);
}

For more details go through the link UTF-8 encoding problem in Spring MVC

Community
  • 1
  • 1
Akhil Sudhakaran
  • 357
  • 2
  • 3
  • 12