运行环境: WIN7 + IE8
开发环境: SPRING MVC
在使用jquery.form的插件进行提交form表单(上传图片、伪ajax)
@RequestMapping("SAVE_INFO")
@ResponseBody
public String saveInfo(HttpServletRequest request, HttpServletResponse response) throws IOException {
String json = "{\"result\": \"success\"}";
return json;
}
var options = { dataType: "json", type: "post", success: function(responseText, statusText){ }, error: function(){} }; $("#formId").ajaxSubmit(options);
当form表单的enctype="multipart/form-data"时,通过jquery.form插件上传文件(win7下的ie8不执行回调函数)
此时需要把java代码改为(spring mvc的@ResponseBody注解设置返回content-type的时候默认取的是请求头信息中的accept第一个值,此时取出的值是application/json,这个时候响应头信息content-type为application/json,这种类型在win7下的ie8有问题)
@RequestMapping("SAVE_INFO")
public void saveInfo(HttpServletRequest request, HttpServletResponse response) throws IOException {
String json = "{\"result\": \"success\"}";
response.setContentType("text/html");
response.getWriter.write(json);
}