.serializeArray() in Jquery

The serializeArray() method serializes all forms and form elements,The serializeArray() method creates an javascript array of objects (name and value) by serializing form values.


<form action="#" method="post" name="formForDesignation" id="formForDesignation">
                            
<input type="text" placeholder="Project managet" name="designation_name" id="designation_name"  required="true">
                               
                               
<input type="text" placeholder="PM"  name="desig_code" id="desig_code" required="true">
                               
                              
<input type="text" placeholder="15000" name="basic_pay" id="basic_pay"  required="true">
                               
<input type="text" placeholder="0.99" name="pf_deduction_percent" id="pf_deduction_percent"  required="true">
                               
<input type="text" placeholder="0.99"  name="esi_deduction_percent" id="esi_deduction_percent"  required="true">
                                
<input type="text" placeholder="1000"  name="other_deduction_amount" id="other_deduction_amount"  required="true">
                               
<input type="text" placeholder="2" name="CL" id="CL"  required="true">
                                
<input type="text" placeholder="2"  name="SL" id="SL"  required="true">
                               
<input type="text" placeholder="15" name="EL" id="EL" required="true">
                                    
<input type="text" placeholder="2" name="other_leave" id="other_leave" required="true">
                               
                               
<button type="submit" id="saveDesignationSavebtn" class="btn btn-success">Save</button>
                           

</form>

syntax:

$(selector).serializeArray()


$('#formForDesignation').serializeArray();

serializeArray() method creates an array of objects (name and value) by serializing form values and return an javascript array of object .  Elements that do not contain a value attribute are represented with the empty string value.

(10) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]

[Object, Object, Object, Object, Object, Object, Object ,...]

Comments

Popular posts from this blog

Hyperparameter tuning for machine learning models.

What is difference between Yield and return Keyword in Python