JQuery $ (this) .serialize () does not send immutable input

When I submit the form using the jQuery post and serialize, I will only submit the elements in the form that has been modified. I want to serialize the whole form. How to do it?

I have HTML.

<form name ="XXX" class="user_goal_form"> <input type="hidden" name ="goalID" value="1"/> <input type="hidden" name ="userID" value="1"/> Fullfilled: <input type="number" class="user_goal_input" name="achievedLevel" value="5"/.> Finished: <input type="checkbox" class="user_goal_input" name="goalCompleted" value="false"/> </form> 

Attached to this is some jQuery:

 $(".user_goal_input").change(function(){ $.post("./handelform.php", {form: $(this).serialize()}) .done(function(data) { $("#userList").html(data); }); 

The contents of the hosted form that I get in handleform.php are just the things that have changed. Never hidden entrances or any entry that has not been modified. How can I do this to submit the whole form?

+4
source share
1 answer

You enter serialization of input instead of form.

You can do it:

 $(".user_goal_input").change(function(){ $.post("./handelform.php", {form: $(this.form).serialize()}) 
+5
source

Source: https://habr.com/ru/post/1485274/


All Articles