title: JQuery (Mobile) /Ajax Undefined returned variable
body: <p>Despite many questions regarding this I cannot seem to find some code that works for my situation, every time I run this code I end up with an undefined variable instead of the desired returned JSON.</p>
  
  <p>My AJAX code is: </p>
  
  <pre><code>$.ajax({
      data: {"serial":account},
      url: 'http://127.0.0.1/MobilePHP/findCustomerName.php',
      dataType: 'json',
      success: function(data){
          window.alert(data);   
      }
  });
  </code></pre>
  
  <p>And my PHP code is: </p>
  
  <pre><code>    &lt;?php
  header("Access-Control-Allow-Origin: *");
  header('Content-type: application/json');
  
  include 'dbConfig.php';
  include 'connectDB.php';
  
  //$account = $_POST['serial'];
  
  $account = 14;
  
  
  $sth = mysql_query("SELECT customer_name AS Name FROM customer_details  WHERE auto_id = $account ");
  
  $rows = array();
  while($r = mysql_fetch_assoc($sth)) {
      $rows ['CustomerName'][] = $r;
  }
  echo json_encode($rows);
  
  
  include 'closeDB.php';
  
  ?&gt;
  </code></pre>
  
  <p>And my JSON from my console is:</p>
  
  <pre><code>{"CustomerName":[{"Name":"Tullaroan"}]}
  </code></pre>
  
  <p>I am really unsure of why I cannot access these variables as it seems to return the right JSON on the console.</p>