How should one submit a traditional JavaScript object along with a jQuery object in the same ajax request?
<form id="fooZ">
<input type="text" name="z0" value="za">
<input type="text" name="z1" value="zb">
<input type="text" name="z2" value="zc">
</form>
var data={ //Created as applicable using JavaScript
"x":[
{"x0":"xa0","x1":"xb0","x2":"xc0"},
{"x0":"xa1","x1":"xb1","x2":"xc1"},
{"x0":"xa2","x1":"xb2","x2":"xc2"}
],
"y":[
{"y0":"ya0","y0":"yb0","y0":"yc0"},
{"y1":"ya1","y1":"yb1","y1":"yc1"},
{"y2":"ya2","y2":"yb2","y2":"yc2"}
]
};
data.z=$('#fooZ').find(':input'); //Doesn't work
data.z=$('#fooZ').find(':input').serializeArray(); //Doesn't work
$.ajax({
type: "PUT",
url: url,
success: function(response){/* ... */},
error: function(jqXHR, status, err) {/* ... */},
dataType: 'json',
data:data
});
Desire for the server to receive:
{
"x":[
{"a":"xa0","b":"xb0","c":"xc0"},
{"a":"xa1","b":"xb1","c":"xc1"},
{"a":"xa2","b":"xb2","c":"xc2"}
],
"y":[
{"a":"ya0","b":"yb0","c":"yc0"},
{"a":"ya1","b":"yb1","c":"yc1"},
{"a":"ya2","b":"yb2","c":"yc2"}
],
"z":{"z0":"za","z1":"zb","z2":"zc"}
}