title: Passing js array to PHP
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/11071584/passing-a-js-array-to-php">Passing a js array to PHP</a>  </p>
  </blockquote>
  
  
  
  <p>i'm stuck jQuery $.post() method, i can't access my through PHP $_POST and I can't figure out why.</p>
  
  <p>Here is the js:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var selectedValues;
  
  
  $("td").click(function() {
  $(this).toggleClass('selectedBox');
  
  selectedValues = $.map($("td.selectedBox"), function(obj) {
          return $(obj).text();   
  });
  
  // $.post('/url/to/page', {'someKeyName': variableName}); //exemple
  $.post('handler.php', 
        {'serializedValues' : JSON.stringify(selectedValues)}, 
        function(data) {
          //debug 
       }
  );
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>And here is the PHP file:</p>
  
  <pre><code>&lt;?php
  if(isset($_POST['serializedValues'])) {
  
          var_dump($_POST['serializedValues']);
          $originalValues = json_decode($_POST['serializedValues'], 1);
          print_r($originalValues);
  
      }
  ?&gt;
  </code></pre>
  
  <p>When I issue a console.log(selectedValues) after selecting some of the td element, it return me this for exemple:</p>
  
  <pre><code> [" 3 ", " 4 "]
  </code></pre>
  
  <p>Something else, when I inspect the sent header through XHR, i get this:</p>
  
  <pre><code> serializedValues:[" 3 "," 4 "]
  </code></pre>
  
  <p>And finally, in php var_dump($_POST) still returns me nothing :(</p>
  
  <p>Some hints ?
  Thanks in advance :)</p>