jquery ajaxSubmit非同期提出の簡単な実現
822 ワード
フロント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();
}