title: Jquery get array details
body: <p>I'm having trouble getting a response back from a Jquery ajax call...</p>
  
  <p>(It's a script to authenticate a user, and needs to return their name and user ID. My understanding was that I could encode it as JSON and get the data in the format below.</p>
  
  <p><strong>It is returning an error of "undefined" for the alert()</strong>. </p>
  
  <p><em>The javascript</em></p>
  
  <pre><code>$.ajax({
   type: "POST",
   url: "myURL.php",
   data: {username: username, password: password},
   success: function(results) {
    //THIS IS WHERE THE PROBLEM IS
    alert('Hi '+results.name); //Should be "Hi Basil Fawlty"
    }
  });
  </code></pre>
  
  <p><em>The PHP (myURL.php)</em></p>
  
  <pre><code>//This comes from a SQL call that returns the following name
  json_encode(array(
   'id'=&gt;1,
   'name'=&gt;'Basil Fawlty'
  ));
  </code></pre>
  
  <p>Any help or ideas on where I am going wrong would be greatly appreciated!</p>
  
  <p>Thanks.</p>
  
  <p><strong>Solution:</strong> The solution was adding a dataType.</p>