更新时间:2023-12-03 14:20:28
IE缓存AJAX请求积极(不仅仅是Firefox,Chrome和Safari)。
有时你需要在请求时设置缓存头控制器。像 cache:false
。我试图像这样修复你的代码
IE caches AJAX requests aggressively (more than Firefox, Chrome, and Safari, anyway).
Sometimes you need to set cache header controller when request. Like cache:false
. I tried to fix your code like this
request.setCharacterEncoding("utf8");
//response.setCharacterEncoding("utf8");
response.setContentType("application/json");
PrintWriter out = response.getWriter();
JSONObject jsonObj = (JSONObject) JSONValue.parse(request.getParameter("para"));
System.out.println(jsonObj.get("message"));
JSONObject obj = new JSONObject();
obj.put("message", "hello from server");
out.print(obj);
我从 application / json更改了你的响应内容类型; charset = utf8
只需 application / json
就行了。