title: fetch rows from mysql using Ajax
body: <p>I am trying to retrieve a row from mysql db using ajax, code bellow:</p>
  
  <pre><code>jQuery.ajax({
                          type: 'POST',
                          url: 'Connection.php',
                          dataType: 'text',
                          data: {'query_id' : query_id},
                          success: function(response){
                              data = response;
                              alert(data['username']); //print undefined!!!
                          },
                          error: function(xhr, ajaxOptions, thrownError){
                              alert("thrownError");
                          }
                      });
  </code></pre>
  
  <p>Here is my mysql php code:</p>
  
  <pre><code>&lt;?php
  
      $con = mysql_connect('****','****','****');
      mysql_select_db("eBay",$con);
  
      $username = $_SESSION['username'];
      $query_id = $_POST['query_id'];
  
      $myquery = "SELECT * FROM  `Output` WHERE `username` =" '$username';
      $query = mysql_query($myquery);
  if ( ! $query ) {
      echo mysql_error();
  }
  
      $data = mysql_fetch_array($query);
      echo ($data);
  
  mysql_close($server);
  ?&gt;
  </code></pre>
  
  <p>In the response I get, I have undefined array cell. Any idea?</p>