前台js
. 代碼如下:
$("#nickForm").ajaxSubmit({
type: "post",
url: "http://localhost:8080/test/myspace.do?method=updateNick¶m=1",
dataType: "json",
success: function(result){
//返回提示信息
alert(result.nickMsg);
}
});
後台封裝:
. 代碼如下:
public ActionForward toUpdateNickName(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
PrintWriter pw = response.getWriter();
JSONObject obj = new JSONObject();
obj.put("nickMsg", "昵稱修改成功!");
pw.print(obj);
pw.close();
}