how can I override jquery's .serialize to include unchecked checkboxes

后端 未结 10 867
暖寄归人
暖寄归人 2020-12-16 14:21

I have read quite a few different methods of having html checkboxes get posted to the server, but I am really looking to do it without modifying anything except for $.serial

10条回答
  •  Happy的楠姐
    2020-12-16 14:49

     var x = $('#formname').serializeArray();
     var serialized = $('#formname').find(':checkbox:not(:checked)').map(function () { 
       x.push({ name: this.name, value: this.checked ? this.value : "false" }); 
     });
    

    try this

提交回复
热议问题