Hi so this may sound odd but lets say currently I am doing this:
var post_data = $('input[name="checks[]"]:checked').map(function() {
return this.value;
}).get();
to get contents of multiple checkboxes into an array to send via AJAX. Now what I ACTUALLY want to do is to construct post_data in a specific way.
I want the value of the checkbox to be stored in the location of the array matching its value. I hope that makes sense :S
so lets say my values of the checkboxes were:
1,5,3,7
i want post_data to be constructed like:
post_data[1] = 1
post_data[5] = 5 etc.
ignoring the fact this may seem stupid, can anyone help me out, I am struggling right now. This is what I was trying, but my very slim knowledge is getting the better of me:
EDIT UPDATE: (code progress)
var post_data = $('input[name="checks[]"]:checked').serialize();
alert(post_data);
$.post('search_item.php', { 'checks[]':post_data,..
many thanks,
you should initialize
post_dataas an objecthere’s a simple example