title: Pass Checkbox Array into AJAX call
body: <p>I'm trying to pass a checkbox array into an AJAX call for a search form im working on:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form id="searchForm"&gt;
      &lt;input type="checkbox" class="typesSearch" name="types[]" value="Fundraiser" checked /&gt;&amp;nbsp;Fundraiser&lt;br&gt;
      &lt;input type="checkbox" class="typesSearch" name="types[]" value="Conference" checked /&gt;&amp;nbsp;Conference&lt;br&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre><code>var types = [];
  
  var eventTypes = document.forms['searchForm'].elements[ 'types[]' ];
  
  for (var i=0, len=eventTypes.length; i&lt;len; i++) {
      if (eventTypes[i].checked ) {
          types.push($(eventTypes[i]).val());
      }
  }
  
  $.ajax({
      url: "https://www.example.com/search.php",
      method: "post",
      data:{
          eventname: eventname,
          types: types
      },
      dataType:"text",
      success:function(data)
      {
          $('#eventsList').html(data);
          $('#eventsList').slick($opts);
      }
  });
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>$event_types = $_POST['types'];
  </code></pre>
  
  <p>The types array is fine on the javascript side, its when it hits the PHP side that $_POST['types'] is read as being empty.</p>
  
  <p>Why is it that $_POST['types'] is read as empty? Is there something in the AJAX call where I need to define that I'm passing in an array instead of a string?</p>