title: Pass Jquery Array to phpself
body: <p>Ok guys. Im new to jquery, and I have a jquery array that I need to pass as a $_POST to the same file which is called index.php. When they click the button I need it to reload the index.php so I can get the POST. Now I'm sure I'm doing something wrong here cause this isn't working. But I'm certain that its something simple that I'm missing, or that I'm doing it all wrong and I mis-understood how this works. Any help is appreciated as I've been on this and trying to figure it out for the last 6 hours. </p>
  
  <p>The index.php also contains the jquery scripts which are below, and the Post check which is</p>
  
  <pre><code>if (isset($_POST['data'])){
  echo "ok, data was sent.&lt;br&gt;";
  
  echo " Data is - " .$_POST['data'];
  }
  </code></pre>
  
  <p>And the Button call</p>
  
  <pre><code>echo "&lt;p&gt;&lt;input type=\"submit\" class=\"input-button\" id=\"btn-add\" value=\"Add Squad\" /&gt;&lt;/p&gt;";
  </code></pre>
  
  <p>Jquery</p>
  
  <pre><code>$(document).ready(function(){
  
  // Get items
  function getItems(exampleNr)
  {
      var count = 0;
      var columns = [];
      $(exampleNr + ' ul.sortable-list').each(function(){
          count++;
  
      columns.push($('#squad'+count).val(), $(this).sortable('toArray').join(','));
      });
  
      return columns.join('|');
  }
  
  $(document).on('click','#btn-get', function() {
      $.post('index.php', {'data': getItems('#squad')}
  });
  });
  </code></pre>