JSFiddle - React, Tailwind, and code Playground
by Claudius
HTML
<form method='post' action=''>
</form>
<form method='post' action=''>
<input type='text' name='foo' value='foo'/>
<div id='target'></div>
</form>
JavaScript
$('form').append("<input type='text' name='bar' value='bar' />");
$('form').append("");
$.ajax({
url: "/echo/html/",
type: "POST",
dataType: "html",
data: {
html: "<textarea name='abc'>test</textarea><input type='button' name='baz' value='baz' />",
delay: 2
},
success: function(data) {
$('#target').replaceWith(data);
console.log(data);
},
error: function(xhr, status, err) {
console.log(status, err);
}
});
$("form").live("click", function(e) {
e.preventDefault();
alert($('form').serialize());
});