title: Passing multiple PHP arrays to JavaScript on AJAX Success
body: <p>I am having a hard time passing arrays from an PHP page to JavaScript using an AJAX request.</p>
  
  <p>I will have to pass the information from multiple php arrays to javascript. I am aware I can use json_encode for this, however, I am having a hard time implementing this. The <code>$name</code> array don't seem to be getting passed, in addition, I will need all arrays to be passed to javascript not just <code>$name</code>.</p>
  
  <p>I appreciate any suggestions with this.</p>
  
  <p>Many thanks in advance!</p>
  
  <p>This is what I tried for passing the <code>$name</code> array (code snippets):</p>
  
  <p>PHP </p>
  
  <pre><code>while($row2 = mysqli_fetch_array($results2)){
      $name[$i] = $row2['prod_name'];
      $price[$i] = $row2['price'];
      $upc[$i] = $row2['upc'];
      $quantity[$i] = $row2['quantity'];
  }
  echo json_encode($name);
  </code></pre>
  
  <p>AJAX</p>
  
  <pre><code>$.ajax({
      url: "invoice-get-data.php?hotItems=1&amp;getArrays=1",
      dataType: "json",
      success: function(data){
          alert(data[0]);
      }
  });
  </code></pre>