Klapsius Klapsius - 2 months ago 10
PHP Question

How to submit HTML multiple forms generated by jQuery

On ajax success i have list of generated forms:

...
success: function (data) {
$el.append('<form method="POST" class="submit_form">Name: '+data[i].namen+'
Id: '+data[i].id+'<br> SomethignElse: <label id="red">'+data[i].se+'</label><br> SomethingElse2: '+data[i].se2+'
<input type="text" name="id" value="'+data[i].id+'" id="id_test" />
<input type="button" class="submit_button1" value="Add"/></form><br>');
i = ++ i;
}
...


Also i have a click functionto submit this forms/form:

$(".submit_button1").click(function(){
//do something
});


but nothing happens on click. Is it possible to submit in this way?

Answer

Please try .on('click' event listner.

$(document).on('click','.submit_button1',function(){
    //do something
});
Comments