?" name="description" /> struts2,jquery?ajaxForm?插件的运用-验证后提交 - 亚搏体育app异常网 亚搏体育app,yabo亚博体育app靠谱吗,yabo168亚博娱乐
当前位置:首页 > Web亚搏体育app > Ajax 技术 > 正文

struts2,jquery?ajaxForm?插件的运用-验证后提交

struts2,jquery?ajaxForm?插件的使用--验证后提交?????






struts2,jquery? ajaxForm插件的使用--验证后提交



<>
method="post">
名称:


地址:


自我介绍:










function?sub()?{
var?name?=?$("#name").attr("value");
//var?name=document.getElementById("name").value;
alert(name);
$.ajax(?{
url?:?"<%=path%>/test/test!submitt.action?customer.name="?+?name,
cache?:?false,
success?:?function(json)?{
alert(json.name);
}
});
}
<%--
demo1
$(document).ready(function()?{
$('#myForm').ajaxForm(?{
//?声明?服务器返回数据的类型.
dataType?:?'json',
success?:?processJson
});
});--%>
<%---
demo2
$(document).ready(function()?{
$('#myForm').ajaxForm(options);
});
var?options={
url:"<%=path%>/test/test!submitt.action",
dataType?:?'json',
success?:?processJson
};
--%>
function?btn1(){
$('#myForm').submit(function(){
$(this).ajaxSubmit(options);
return?false;
});
}
function?btn2(){
$('#myForm').ajaxForm(options);
}
function?btn(){
$('#myForm').ajaxForm({
url:"<%=path%>/test/test!submitt.action",
dataType?:?'json',
success?:?processJson
});
}
var?options={
url:"<%=path%>/test/test!submitt.action",
dataType?:?'json',
success?:?processJson
};
function?processJson(json)?{
//?'data'是一个json对象,从服务器返回的.
alert(json.name+"成功了");
}
alert("sdf");




???下面是PO??package?po;

public?class?Customer?{
private?String?name;
private?String?address;
private?String?comment;
public?String?getName()?{
return?name;
}
public?void?setName(String?name)?{
this.name?=?name;
}
public?String?getAddress()?{
return?address;
}
public?void?setAddress(String?address)?{
this.address?=?address;
}
public?String?getComment()?{
return?comment;
}
public?void?setComment(String?comment)?{
this.comment?=?comment;
}
}?????下面是Action??package?test;

import?po.Customer;

import?com.opensymphony.xwork2.ActionSupport;
public?class?CustomerAction?extends?ActionSupport?{
private?static?final?long?serialVersionUID?=?1L;
private?Customer?customer?=?new?Customer();
public?String?init()?{
return?"init";
}
public?String?submitt()?{
System.out.println(customer.getName());
System.out.println(customer.getAddress());
System.out.println(customer.getComment());
return?"checkPerson";
}
public?Customer?getCustomer()?{
return?customer;
}
public?void?setCustomer(Customer?customer)?{
this.customer?=?customer;
}
public?static?long?getSerialversionuid()?{
return?serialVersionUID;
}

}
????最后是struts.xml??





/index.jsp
/ok.jsp

customer



????????????????????????????????????????????????????????????????????????
友情链接
工具之家
异常 - Exception - Copyright ? 2014 - 2014 - 亚搏体育app异常网 - 鄂ICP备14001750号 - 网站地图