//向服务器发送表达数据
$("#regRe").click(function() {
//把表单的数据进行序列化
var params = $("form").serialize();
//使用jQuery中的$.ajax({});Ajax方法
$.ajax( {
url : "../user!gainUserInfo.action",
type : "POST",
data : params,
dataType : "json",
success : function(data) {
//清空显示层中的数据
$("#message").html("");
//为显示层添加获取到的数据
//获取对象的数据用data.userInfo.属性
$("#message").append(
"<div><font color='red'>用户ID:" + data.user.id
+ "</font></div>").append(
"<div><font color='red'>用户名:" + data.user.username
+ "</font></div>").append(
"<div><font color='red'>密码:" + data.user.password
+ "</font></div>")
}
});
});