KenavR KenavR - 10 months ago 141
Ajax Question

jquery form.serialize and other parameters

Is it possible to send a

form.serialize()
object and other paramters with a single
$.ajax()
request?

Example:

$.ajax({
type : 'POST',
url : 'url',
data : {
$('#form').serialize(),
par1 : 1,
par2 : '2',
par3: 232
}
}


If not what's the best way to submit a form together with other parameters.

Thanks

Answer Source

serialize() effectively turns the form values into a valid querystring, as such you can simply append to the string:

$.ajax({
    type : 'POST',
    url : 'url',
    data : $('#form').serialize() + "&par1=1&par2=2&par3=232"
}