jQuery异步提交form表单
2016-12-13 10:06
323 查看
jQuery异步提交form表单
这个其实挺简单的,只是一开始我想错了,一开始我打算用jQuery +jQuery.form插件来做,其实不必的,只需要jQuery插件就可以了。
首先,在jsp页面中导入jQuery,
<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
=======================================================
<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>
这个其实挺简单的,只是一开始我想错了,一开始我打算用jQuery +jQuery.form插件来做,其实不必的,只需要jQuery插件就可以了。
首先,在jsp页面中导入jQuery,
<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方案)
Jquery来对form表单提交,下面是一个form表单,里面没有action字段,我们来用Jquery注册事件进行提交,<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>
相关文章推荐
- $.ajax 和 jquery.form.js实现表单异步提交
- 使用jQuery.form插件,实现完美的表单异步提交
- jQuery异步提交form表单
- Jquery.Form 异步提交表单实例
- jquery表单插件 jquery.form(异步提交)(学习总结)
- 异步提交form的时候利用jQuery validate实现表单验证
- Jquery.Form 异步提交表单实例
- 异步提交form的时候利用jQuery validate实现表单验证
- 如何在异步提交form的时候利用jQuery validate实现表单验证
- Jquery 异步提交表单有form无form的时候处理方式
- 使用jquery插件jquery.form.js,异步提交表单 1
- JQuery异步提交表单(不使用jQuery.form插件)
- 使用jQuery.form插件,实现完美的表单异步提交
- 使用jQuery.form插件,实现完美的表单异步提交
- 使用jQuery.form插件,实现完美的表单异步提交
- 使用jquery插件jquery.form.js,异步提交表单 1
- jQuery异步提交form表单
- 使用jQuery.form插件实现表单异步提交+上传文件
- 使用jQuery.form插件,实现完美的表单异步提交
- 使用jQuery.form插件,实现完美的表单异步提交【转发】