I have a bunch of forms as rows in a table. There's a submit button at the end of each row. When this button is clicked, my JQuery function creates two text boxes and another submit button. I want the POST variables from the both forms, so I can ultimately pass it onto my php script via AJAX. What would be the best way of doing this?
<script>
<?php
$ajax_var = <<<HTML
<form method="post" id="ajax_form">
<div id="ajax_input">
<input type="text" name="user_name" placeholder="Your name">
<br>
<input type="text" name="user_email" placeholder="Your e-mail">
<br>
</div>
<input id="ajax_submit" type="submit" value="submit">
</form>
HTML;
$ajax_var = str_replace("\n",'',$ajax_var);
?>
$("form").submit(function(e)
{
e.preventDefault();
$("#wrapper").prepend('<?php echo "$ajax_var" ?>');
});
$("form#ajax_form").submit(function(e)
{
e.preventDefault();
});
</script>
The last JQuery function does not work as intended. Pressing the ajax-created submit reloads the page :S