title: jQuery Pass Multiple Checkbox Value to PHP using Ajax
body: <p>I have jQuery to get multiple checkbox value.</p>
  
  <p>You can refer for the demo <a href="https://jsbin.com/cosebiqilo/edit?html,output" rel="nofollow noreferrer">here</a></p>
  
  <p>The function for that jQuery is OK, when We tick the checkbox then We can see what We choose based on data-id after btnUpdate click.</p>
  
  <p>But now I want to pass and store it to database using PHP by Ajax.
  So Example output,</p>
  
  <pre><code>1 -&gt; read
  1 -&gt; update
  2 -&gt; update
  </code></pre>
  
  <p>Then save it to database on table:</p>
  
  <pre><code>ID | chkStatus
  1  | read
  1  | update
  2  | update
  </code></pre>
  
  <p>Here is the HTML</p>
  
  <pre><code>&lt;table&gt;
  &lt;tr&gt;
    &lt;th&gt;Nama&lt;/th&gt;
    &lt;th&gt;Create&lt;/th&gt;
    &lt;th&gt;Read&lt;/th&gt;
    &lt;th&gt;Update&lt;/th&gt;
    &lt;th&gt;Delete&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;coba&lt;/td&gt;
    &lt;td&gt;&lt;input type="checkbox" data-id="1" data-tipe="create"&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="checkbox" data-id="1" data-tipe="read"&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="checkbox" data-id="1" data-tipe="update"&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="checkbox" data-id="1" data-tipe="delete"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;coba 2&lt;/td&gt;
    &lt;td&gt;&lt;input type="checkbox" data-id="2" data-tipe="create"&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="checkbox" data-id="2" data-tipe="read"&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="checkbox" data-id="2" data-tipe="update"&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="checkbox" data-id="2" data-tipe="delete"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;input type="button" id="btnUpdate" value="Update"/&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>
    </p>
  
  <p>jQuery</p>
  
  <pre><code>$(function(){
    $('#btnUpdate').click(function(){
      var cb = [];
      $.each($('input[type=checkbox]:checked'), function(){
        cb.push($(this).data('id') + ' -&gt; ' +$(this).data('tipe'));
      });
      $('#status').val(cb.join("\n"));
    })
  });
  </code></pre>