Kevin Kevin - 4 months ago 6x
Javascript Question

How to post multiple sets of data as a single variable in an ajax request?

I currently have a jQuery ajax function which posts a multi-dimensional array to my server.

type: "POST",
url: "Default.aspx/SaveQuoteProcesses",
data: "{'items':" + JSON.stringify(jaggedArray) + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg){
error: function (){

Here is an example of the dataset I'm currently posting to the server:

{"QpcOpsID":26,"QpcQitID":"63","QpcPprID":6,"PprQuestion":"How many colors?","AnswerValue":"4"}

I now need to send a regular array to the server in the same AJAX request.

["22", "20", "26"]

How can I include this new array in the existing javascript object?

var data = {
  items: jaggedArray,
  newArray: ["22", "20", "26"]

And then just JSON.stringify(data).