Tuesday, January 21, 2020

Submit dynamic checkbox in jquery datatable



$('#btnSubmit').click(function () {
  var postData = $('#frm').serialize();
  var idParam = $('#id').val();
  var url = "your_url.php";

  var tbl = $('#dtTable').DataTable();
  var dt = tbl.$('input[type="checkbox"]').serialize();
  var postData = dt+'&id='+idParam;

  $.ajax({
    method: "POST",
    url: url,
    data:postData,
  })
    .done(function(data) {
      var msg = jQuery.parseJSON(data);
      if(msg.status == 'success'){
        $('#modalPopup').modal('toggle');
      }else{
        alert('Failed! ' + msg.msg);
      }

    });
});

No comments:

Post a Comment