title: Return php array using ajax
body: <p>I am trying to fill a html table with an array. The function is in php and when I call it, without ajax, but just with php it works fine but as soon as I try calling it using ajax, it returns an empty array</p>
  
  <pre><code>        function getAJAX(){
          var token = window.token;
          $.ajax({ url: 'functions.php',
                   data: {action: 'openSales', access: token}
                   type: 'post',
                   success: function(output) {
                                document.getElementById('OpenSales').innerHTML = '';
                               var output = jQuery.parseJSON(output);
                                makeTable($('#OpenSales'),output,'overdueSales');
                            }
          }); 
      }
  </code></pre>
  
  <p>The makeTable function does work when called outside the ajax function so that is not the problem, the php code is</p>
  
  <pre><code>        if(isset($_POST['action']) &amp;&amp; !empty($_POST['action'])) {
          $action = $_POST['action'];
          $token = $_POST['access'];
          switch($action) {
              case 'openSales' : echo json_encode(getOverdueSales($token)); break;
              case 'blah' : blah();break;
          }
      }
  </code></pre>
  
  <p>Anyone see what I am doing wrong here?</p>