javascript - Internet Explorer 中的 Json 响应问题

标签 javascript json internet-explorer response

我在 Internet Explorer 中使用 ajax 显示 json 响应时遇到问题。其他浏览器正确显示它。但在 Internet Explorer 中显示为??????。

响应 header 是

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

但是在 Internet Explorer 中,响应正文给出为

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

在所有其他浏览器中都能正确显示

最佳答案

我已经找到了答案。这是服务器的问题。我们必须在服务器中将响应内容类型设置为 text/plain。以下是解决我的问题的代码。

   @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);
}

欲了解更多详情,请访问链接 UTF-8 encoding problem in Spring MVC

关于javascript - Internet Explorer 中的 Json 响应问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34938800/

相关文章:

javascript - 如何维护列表项的指针[jquery]

javascript - 为什么这个 Jsfiddle 不起作用 : tracking. js 人脸检测示例

html - 从 JSON 数组读取到 Grails HTML Select 标签

JavaScript。如何停止数组的重复输出并添加 bool 值?

html - CSS 移除默认蓝色边框

javascript - JQuery - 根据 2 个不同的选择下拉值显示隐藏 DIVS

Javascript 奇怪的 StackOverflow 错误

python - 使用 urllib、urllib2 和 json 模块为 Google map API 创建客户端时出现 KeyError

c++ - UIA 无法获得比较端点以在 Internet Explorer 中的文本选择和文档范围之间工作

javascript - 图片显示中的浏览器依赖问题