jquery form serialize and other parameters

jquery form serialize and other parameters  using -'jquery,ajax,forms,serialization'

Is it possible to send a form.serialize() object and other paramters with a single $.ajax() request?


    type : 'POST',
    url : 'url',
    data : {
        par1 : 1,
        par2 : '2',
        par3: 232

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


asked Sep 14, 2015 by NevilleFazli
0 votes

3 Answers

0 votes

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

    type : 'POST',
    url : 'url',
    data : $('#form').serialize() + "&par1=1&par2=2&par3=232"
answered Sep 14, 2015 by MartyBetheld
0 votes

Alternatively you could use form.serialize() with $.param(object) if you store your params in some object variable. The usage would be:

var data = form.serialize() + '&' + $.param(object)

See http://api.jquery.com/jQuery.param for further reference.

answered Sep 14, 2015 by DorisAbernat
0 votes

I dont know but none of the above worked for me, Then i used this and it worked :

In form's serialized array it is stored as key value pair

We pushed the new value or values here in form variable and then we can pass this variable directly now.

var form = $('form.sigPad').serializeArray();
var uniquekey = {
      name: "uniquekey",
      value: $('#UniqueKey').val()
answered Sep 14, 2015 by KristalHbpwm