I am using jquery ajax to post form contents to the server like this:
$.ajax({
type: type,
dataType: "json",
url: url,
data: form.serialize(),
success: onSuccess
});
I have to send an array of data as though it came from a checkbox.
I don't want to create a hidden checkbox on the fly and append() it to the form before submission. I dont see any other methods in the form jquery api that could help me. Any help?
Thanks, Chris.
I realize this post is old and may not be exactly the same as my case -- but it came up in a search when I had a very similar issue, so here it is. In my case, there was a specific data format the server was expecting:
$_POST['Category'] = Array([id]=>value)
so I used a nested object to format the data and jQuery to submit via Ajax POST. In this example we are fetching some Category IDs from DOM elements, which are then to be used as keys when the data is saved, and the values derived via a function: