title: Send array data through AJAX
body: <p>I have the following issue.</p>
  
  <p>I'm trying to send a <code>AJAX</code> call whenever a <code>checkbox</code> is checked. The value of the <code>checkbox</code> is send to my <code>PHP</code> file where the DB will be checked to get all the data of that value.</p>
  
  <p>The problem is, I would like to show the data on the page but I don't know how.</p>
  
  <p>Below is my code:</p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;input type="checkbox" name="category[]" id="1" value="1" /&gt; &lt;label for="1"&gt;Administratieve Sector&lt;/label&gt;&lt;br /&gt;
  &lt;input type="checkbox" name="category[]" id="2" value="2" /&gt; &lt;label for="2"&gt;Bouw Sector&lt;/label&gt;&lt;br /&gt;
  &lt;input type="checkbox" name="category[]" id="3" value="3" /&gt; &lt;label for="3"&gt;Financiele Sector&lt;/label&gt;&lt;br /&gt;
  &lt;input type="checkbox" name="category[]" id="4" value="4" /&gt; &lt;label for="4"&gt;Gezondheidszorg Sector&lt;/label&gt;&lt;br /&gt;
  &lt;input type="checkbox" name="category[]" id="5" value="5" /&gt; &lt;label for="5"&gt;Horeca- en toerisme Sector&lt;/label&gt;&lt;br /&gt;
  </code></pre>
  
  <p><strong>JQuery:</strong></p>
  
  <pre><code>function calculate() {
  
      var arr = $.map($('input:checkbox:checked'), function(e, i) {
          return +e.value;
      });
  
      $.ajax({ 
          url: '/company/test.php',
          data: {key: arr, i: 1},
          type: 'post',
          success: function(output) {
              obj = JSON.parse(output);
  
              console.log(obj);
              // Don't know where to go next
          }
      });
  }
  
  calculate();
  
  $("div[class='col-md-12'").delegate("input:checkbox[name='category[]']", 'click', calculate);
  </code></pre>
  
  <p><strong>PHP:</strong></p>
  
  <pre><code>&lt;?php
  
  require_once '../core/init.php';
  
  $v = new Vacatures();
  
  if(isset($_POST['key']) &amp;&amp; isset($_POST['i']) &amp;&amp; !empty($_POST['key'])) {
  
      $key = $_POST['key'];
      $i = $_POST['i'];
  
      $vacs = $v-&gt;getFiltered($key, $i);
  
      echo json_encode($v-&gt;data());
      exit();
  }
  
  require_once VIEW_ROOT . '/company/test_view.php';
  </code></pre>
  
  <p><strong>UPDATE (Content of <code>obj</code>)</strong></p>
  
  <pre><code>[Object]0: Objectcategory: "1"company: "c1"content: "test"foto: "test"id: "2"region: ""title: "Test"__proto__: Objectlength: 1__proto__: Array[0]
  </code></pre>