title: How to return JSON data from an AJAX call
body: <p>I have a JSON object I am returning from the database.  It is formatted correctly.  I am trying to access the data in it with an AJAX call.  Here is my AJAX.</p>
  
  <pre><code>$.ajax({
          url: '&lt;?php echo site_url('find_representatives/find_rep_by_address/get_coordinates'); ?&gt;', 
          dataType: 'json',
          data: '',
          success: function(data, status, xhr) {
               alert(data);
          },
          error: function(xhr, status, error) {
               alert(status);
          }
  });
  </code></pre>
  
  <p>I have '' in my data because I am looking for all of the data.  I tried putting 'id' there (there is an ID in my JSON object, but the function stopped working when I did that.  When I alert 'data' I get an object, but where I alert 'data.id' I get 'undefined.'  What am I doing wrong?  This is my first AJAX call.  The URL is valid.  I checked.</p>