Serialize Dynamic Form
Serialize Dynamic Form
I am having trouble serializing inputs from a dynamic form and when I inspect the element using firebug it doesn't appear the value is being updated as well.
Dynamic creation of the form
$(document).on('click',"#userlists",function() {
var userID = $("#userlists").val().replace("#","");
$.ajax({
type:'Get',
url: 'http://localhost:8080/sdd/user/'+userID,
dataType: 'jsonp',
crossdomain: true,
success: function(data){
var userinfo = '<div><form id="EditUserForm" class="navbar-form" accept-charset="UTF-8" >ID:<input type = "text" id ="id" value ="'+data["@rid"]+'" readonly /><br /> Name:<input type = "text" id ="name" value ="'+data.name+'"/><br /> Email:<input type = "text" id ="email" value ="'+data.email+'"/><br /> <input type="submit" name="submit" value="Update User" class ="btn btn-mini"/></form></div>';
/* insert the html string */
$("#selecteduser").html( userinfo);
}});
Attempt to Serialize and Post
$(document).on('submit',"#EditUserForm",function(){
//add new enhanced user using jQuerys ajax call
$.ajax({
type:'POST',
url: 'http://localhost:8080/sdd/user?',
data:$('#EditUserForm').serialize(),
crossdomain: true,
success: function(response) {
alert("Success");
}});
return false;
});
The data is blank. I have also played around by printing to the console $("#EditUserForm").find('input') and ($("#EditUserForm").closest('form'); .. and trying to serialize them as well. The values never change from my default value and serialize blank as well.