I am trying to figure out how to append two more values to the serialize method in JQuery. I have the following code to submit a form with ajax and have two more variables t
If you change serialize()
to serializeArray()
you can push values into the array :
var formData = $('#contact_form').serializeArray();
formData.push({ name: "<something>", value: "<somevalue>" });
submitForm(formData);
The data can still be sent in the same way as you would with the serialize()
method, using the $.ajax()
method
You can add new values by appending to your variable:
formData += '&var1=blah&var2=blah';