<script type="text/javascript"src="<%=request.getContextPath()%>/js/jquery-1.4.2.js"></script>
然後在jQuery的ready方法中定義form提交時的動作就可以了,
$(document).ready(function() {
// 使用 jQuery異步提交表單
$('#editRealMsgForm').submit(function() {
jQuery.ajax({
url:'editRealMsg.eri',
data:$('#editRealMsgForm').serialize(),
type:"POST",
beforeSend:function()
{
$('#submitButton').hide();
$('#editRealMsgImg').show();
},
success:function()
{
$('#editRealMsgImg').hide();
$('#modifyButton').show();
$('#realName').attr("disabled","true");
$('#tel').attr("disabled","true");
}
});
returnfalse;
});
});
現在這個form就綁定好jQuery封裝的異步提交方法了,簡單吧!
=====================================================
the secondmethod
no input id
=======================================================
Jquery來對form表單提交(mvc方案)
<form method="post"id="documentForm">
<input type="hidden" id="hidId" name="hidId"value="<%=Request.QueryString["id"]%>" />
<input type="hidden" id="hidAction" name="hidAction"value="<%=Request.QueryString["action"]%>" />
<divclass="fieldbody">
<div class="tagsiglebody">
<table class="create">
<tr>
<th class="w100">
關鍵字:
</th>
<td class="nes">
<input type="text" id="txtKeyword" name="txtKeyword"class="txt w250" value="<%=ViewData.eval_r("keywords") %>"
isnull="0" />
關鍵字請用逗號隔開
</td>
</tr>