jquery通过submit()和serialize()提交表单
<script type="text/javascript">$(function() {
$('#form1')。submit(function() { //当提交表单时,会发生 submit 事件。
//此处可做表单验证
//… …
var postData = $("#form1")。serialize();//序列化表单,后台可正常通过post方法获取数据
$.ajax({
type: "POST",
url: "/member/member/post_member",
data: postData,
success: function(msg) {www.9ask.cn/yangzhou/
if (msg == 0) {
alert('操作成功');
window.location.href = '/member/member';
} else {
alert(msg);
}
}
});
});
});
</script>
<div>
<form id="form1" onsubmit="return false;">
<!--表单内容部分-->
<input type="reset" value="重置" />
<input type="submit" value="提交" />
</form>
</div>
页:
[1]