Organizational Research By

Surprising Reserch Topic

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?

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
    

asked Sep 14, 2015 by NevilleFazli
0 votes
8 views



Related Hot Questions

3 Answers

0 votes

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"
}
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()
};
form.push(uniquekey);
answered Sep 14, 2015 by KristalHbpwm

...