我有一个像下面这样的html,其中有多个表单。我是使用JSTL生成的,因此这个数字可能会根据我的数据库中注册的内容而有所不同。每个表单都有自己的提交按钮。
基本上,我想使用form Plugins ajax submit按钮,但我不知道如何引用表单。
<form id="form-1" action="approve.htm">
<textarea name="comment"> </textarea>
<input type="submit" value="Add Comment" />
</form>
<form id="form-2" action="approve.htm">
<textarea name="comment"> </textarea>
<input type="submit" value="Add Comment" />
</form>
.
.
.
<form id="form-10" action="approve.htm">
<textarea name="comment"> </textarea>
<input type="submit" value="Add Comment" />
</form>我的问题是,我如何知道哪个表单id正在使用jQuery提交。
我不知道在对ajax表单的调用中应该放入哪个表单名称。
$('#form-name?').ajaxForm();发布于 2010-07-18 00:11:31
默认情况下,它会提交当前的表单,例如你在其中点击“添加评论”的表单,所以只需通过标签名称选择它们:
$('form').ajaxForm();或者(特别是如果页面上有其他表单),给它们一个类,例如:
<form id="form-1" class="commentForm" action="approve.htm">并按类选择:
$('form.commentForm').ajaxForm();重要的是要记住,.ajaxForm()并不发送它准备的<form>。您只需选择一些表单并准备them...they,所有这些表单仍将单独提交。因此,这里需要做的就是使用一个选择器,它只选择您想要通过AJAX提交的表单。
https://stackoverflow.com/questions/3272235
复制相似问题