神山树9196 2017-05-04 02:59 采纳率: 0%
浏览 884

json接收不到,求大神指点明津

$.ajax({
url:"<%=request.getContextPath()%>/login_update.action",
type:"post",
data:{
id:id,
name:name,
email:email
},
dataType:"json",
success:function(obj){
if(obj){
alert("修改成功!");
location.href = "<%=request.getContextPath()%>/login_toList.action;
}
else{
alert("修改失败!");
}
}
}) 前台ajax
后台接收public String update() throws SQLException {
//通过ID找对象
UserInfo userInfo = UserInfoDataProvider.getInstance().getUserInfoById(id);
System.out.println("==============================================================="+userInfo.getName());
//更新
UserInfoDataProvider.getInstance().updateUserInfo(userInfo);

    HttpServletResponse response = ServletActionContext.getResponse();

    JSONObject json = JSONObject.fromObject(userInfo);

    try {
        response.getWriter().write(json.toString());
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return null;

} ,接收到的name不是我要更新的,还是原来的,我的那个json数组写的是否正确?
  • 写回答

3条回答 默认 最新

  • 行书开发 2017-05-04 03:05
    关注

    你用的id,name两个参数,你还没有解析出来呢?而你的返回值是null

    评论

报告相同问题?