日期:2014-05-17  浏览次数:20793 次

IE8下jquery的$.ajaxBUG,大家帮帮忙啊!
JS部分
  $.ajax(
{
url:"m.do?action=getLoad",
type:"POST",
data:{
name:'username',
password:'password'
},
dataType:'json',
success:function(data,textStatus){
alert(data);
},
error:function(XMLHttpRequest,textStatus,errorThrow){
alert(errorThrow);
alert(XMLHttpRequest.responseText);
$("#div1").html(errorThrow.toString());
},
complete:function(XMLHttpRequest,textStatus){
alert(3);
}
}

);

servlet部分
  public class MyJsonController extends MultiActionController{


public void getLoad(HttpServletRequest request,HttpServletResponse response) throws IOException{
System.out.println(request.getParameter("name")+":"+request.getParameter("password"));

response.setContentType("application/x-json");
response.setHeader("Cache-Control", "no-cache");
response.setCharacterEncoding("utf8");
PrintWriter pw = response.getWriter();

JSONObject apple=JSONObject.fromObject("{apple:'apples'}");
pw.println(apple);
return;
}
}


火狐和谷歌浏览器都没问题,,IE8能到servlet,但是回不来,报Error: Could not complete the operation due to error c00ce56e.
如果把response.setContentType("application/x-json");去掉竟然IE8就行,大家帮忙解决解决啊,到底为什么?感激不尽。

------解决方案--------------------
返回的json格式 用 双引号 而非单引号


楼主 试试