Ajax数据传递暨利用js进行表单数据回显

2023-11-09

问题一: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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Ajax数据传递暨利用js进行表单数据回显 的相关文章

随机推荐