无法提交生成的表格 [英] Can't submit generated form
问题描述
我想提交使用AJAX动态创建(由先前的表单提交)的表单,但是我无法使其成功运行.生成的表单具有显示的格式,并且已成功创建
I want to submit a form that's been created dynamically (by a previous form submit) using AJAX, but I'm not able to get it to work successfully. The generated form has the format shown, and is being created successfully
<div id="1" class="container-element">
<h3>HEADER</h3>
<form id="formCELL" name="form_1" action="refresh.php" method="post">
<div class="panel-body">
<div class="col-xs-10 com">CONTENT GOES HERE</div>
<div class="col-xs-2 btn"><button class="btn btn-primary" id="refresh" type="submit">Refresh</button> </div>
</div>
</form>
</div>
用于生成表单,然后刷新内容的函数在这里.现在,单击刷新按钮时未输入 $('#formCELL').submit(function(event)
函数.
The functions used to generate the form, and then refresh the content, is here. Right now, the $('#formCELL').submit(function(event)
function isn't being entered when the refresh button is clicked.
$(document).ready(function() {
$('#formMAIN').submit(function(event) {
//formCELL is generated here through AJAX call.....
});
$('#formCELL').submit(function(event) {
// process the form
alert("about to submit");
//AJAX call to go here
event.preventDefault();
});
});
我想这个问题与我在 $(document).ready
中包含Submit函数有关,因为我尚未刷新的表单目前尚未创建,但我不确定如何从这里继续.
I'm guessing that the problem has to do with me having my submit function within $(document).ready
, that the form I want to refresh hasn't been created at this point yet, but I'm not sure how to continue from here.
推荐答案
尝试:
$(document).on('submit', '#formCELL', function(event) { ... });
我为您创建了一个jsFiddle: JsFiddle
I create a jsFiddle for you: JsFiddle
我根据您的需要修改了jsFiddle.现在,第一种形式生成由seconf提交功能
I modify the jsFiddle according your needs. Now first form generate second form that is handled by seconf submit function
这篇关于无法提交生成的表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!