PaulMasterson PaulMasterson - 1 year ago 70
Ajax Question

Can't submit generated form

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">
<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>

The functions used to generate the form, and then refresh the content, is here. Right now, the
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



I'm guessing that the problem has to do with me having my submit function within
, 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.

Answer Source


$(document).on('submit', '#formCELL', function(event) { ... });

I create a jsFiddle for you: JsFiddle

I modify the jsFiddle according your needs. Now first form generate second form that is handled by seconf submit function

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download