How to send a checkbox group via ajax in jquery?

前端 未结 4 932
暗喜
暗喜 2021-01-14 07:39

I need to send a group of checkboxes (with some other data as well) via ajax in jquery.

What I\'ve done so far is:

var arr = $(\'#somediv input[type         


        
4条回答
  •  感动是毒
    2021-01-14 08:40

    Ran into a similar problem and after much pulling of hair fixed it with SerializeArray

    HTML

    
    

    jQuery

    var userList = $('input[type=checkbox]:checked').serializeArray();
    

    PHP

    $userList = $_POST['userList'];
    for($i=0;$i

提交回复
热议问题