Well from what I saw serialize() did not serve, so how do you just want to get the values of inputs and selects. You can use $.each(). As follows :
$(function(){
var print=function(){
var data = {};
$('#form1 input, #form1 select').each(function(){
data[$(this).attr("name")] = $(this).val();
});
console.log(data);
};
print(); // irá printar o objeto no console
});
Basically what this code does is go in each select and each input present within the form, take the name attribute and its value. Then add this to the date object so that the, the key is the field name (which can be input or select) and the value is the field value.
Enclosed within a function, it can be called when and the way you need it.
I hope I’ve helped ;)
Because the
$('#form1').serialize()
didn’t work? What happened?– Artur Trapp
@Arturotemplário do not know if it can be the fact of the form is dynamic and the data he understands that do not exist yet, for having been created after the declaration of the function
– WMomesso