Send multiple checkbox data to PHP via jQuery ajax()

后端 未结 6 1100
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-28 08:31

I want to submit a POST form that contains a textarea field and an input field(s) (type=\"checkbox\" with an arbitrary/variable number of checkboxes) on my website via jQuer

6条回答
  •  孤独总比滥情好
    2020-11-28 09:12

    var myCheckboxes = new Array();
    $("input:checked").each(function() {
       data['myCheckboxes[]'].push($(this).val());
    });
    

    You are pushing checkboxes to wrong array data['myCheckboxes[]'] instead of myCheckboxes.push

提交回复
热议问题