Get data array from checkbox list in jquery
I have multiple checkbox list that can be selected
name="campaign_ids"
I have a function setup in jquery that looks like this:
<script>
$('form#manage_campaigns').submit(function(){
var formData = $(this);
$.post(site_url + 'm/affiliates/ajax?action=save_affiliate_campaigns&aid=__aid__', formData, function(data) {
$('#man_cam_container').fadeOut('fast', function(){
$('#man_cam_container').html(data).fadeIn('slow');
setTimeout(function () {
$('#manage_campaigns').dolPopupHide({});
}, 2000);
});
});
开发者_Go百科 return false;
})
</script>
What I'm trygin to figure out is how to post the array of "campaign_ids" to the URL. Any suggestions on what I'm doing wrong?
name="campaign_ids[]"
should do it
Try doing this, using map
:
var formData = {ids: $(this).find('[name="campaign_ids"]').map(function(){
return this.value;
}).get() };
精彩评论