问题一:Ajax传递整个表单数据:
function createCustomer() {
$.post("${pageContext.request.contextPath}/list/add.do",
$("#new_customer_form").serialize(),function(data){
if(data =="OK"){
alert("客户创建成功!");
window.location.reload();
}else{
alert("客户创建失败!");
window.location.reload();
}
});
}
其中,new_customer_form为表单的ID,serialize()数据序列化,function(data)中的data即为后台返回在值;
问题二:Ajax传递某个数据:
function editCustomer(id) {
$.ajax({
type:"get",
url:"${pageContext.request.contextPath}/list/edit.do",
data:{"id":id},
success:function(data) {
$("#edit_cust_id").val(data.cust_id);
$("#cust_name").val(data