I need to create a variable to use with in the ajax data property. The out put needs to look like this:
data: { brand: 1, brand: 4 }
I have a few checkboxes, depending on what the user clicks I would like the list to change.. currently I have this:
$('body').on('change','form[name=checkboxes] input',function(){
var result = [];
$.each( $('form[name=checkboxes]').serializeArray(), function() {
result.push({
name: this.name,
value: this.value
});
});
console.log(result);
$.ajax({
type: "POST",
url: "/echo/html/",
data: { brand: 1, brand: 4 }
}).done(function( data ) {
});
});
But result outputs objects.

Does anyone have any suggestions, am I on the right track?
I've created a JS fiddle to help http://jsfiddle.net/samstimpson/hzy9jxve/
Edit
My goal is to build this "data: { brand: 1, brand: 4 }" dynamically. If the user clicks a load of checkboxes I ultimately want to pass a list in to the ajax data value.. what Ive done above may not be correct, Im looking for a way of doing this.