• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

jquery ajax data parameters mixed

How would I do the following (mix the data parameter);

data: options.getparam + "&" + { 'mode' : options.mode : modeb : options.modeB }


where getparam is the following from the calling function

'getparam' : $('form').serialize()  which is the form elements  in name&value format
0
KeithMcElroy
Asked:
KeithMcElroy
2 Solutions
 
Chris StanyonCommented:
A couple of way of mixing data. serialize() returns a string (like a querystring) so you would need to concatenate your additional variables on to it:

data : options.getparam + "&mode=" + options.mode + "&modeb=" + options.modeB;

Alternatively, you could use serializeArray() to return an array instead of a string and then 'push' new values on to.

myData = $('form').serializeArray();
myData.push( { name: "mode", value: options.mode } );
myData.push( { name: "modeb", value: options.modeB } );

Then just post the myData array in your ajax call:

data: myData
0
 
JonNormanCommented:
have a look at the param function too, this takes an array (does not require a form) and serializes that:

http://api.jquery.com/jQuery.param/
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now