这篇文章主要介绍了jquery ajaxSubmit 异步提交的简单实现。需要的朋友可以过来参考下,希望对大家有所帮助
前台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();
}
时间: 2024-10-20 03:48:42