ajax如何接收返回的json数据
服务器端:
response.setContentType("application/json;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
PrintWriter pw = response.getWriter();
pw.write(retJSONString);
前台页面:
xmlHttp.open("POST", BeanName);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.send(str);
//ajax返回处理
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4 && xmlHttp.status==200){
var jsonObj=eval(xmlHttp.responseText); //这样不行.......
.....
}