title: Reddit API - difference between API and appending .json and getting front page info
body: <p>I am newcomer with making applications dealing with other API's, especially ones that require OAuth authentication.</p>
  
  <p>For now, I am trying to simply fetch information about the front page listing of Reddit in my application.</p>
  
  <p>I am looking at this Reddit API doc <a href="https://www.reddit.com/dev/api" rel="nofollow">here</a>, but then I am reading that to get a JSON representation of Reddit you just have to add a .json after the url. </p>
  
  <p>So I am sending a HTTP GET request like: </p>
  
  <pre><code>$(document).ready(function () {
  
      httpGetAsync("https://www.reddit.com/.json");
  
  });
  
  function httpGetAsync(url) {
      var xmlHttp = new XMLHttpRequest();
      xmlHttp.onreadystatechange = function () {
          if (xmlHttp.readyState == 4 &amp;&amp; xmlHttp.status == 200)
              alert(JSON.stringify(xmlHttp.responseText, null, 4));
      }
      xmlHttp.open("GET", url, true); // true for asynchronous 
      xmlHttp.send(null);
  }
  </code></pre>
  
  <p>But this seems to be only returning what seems is the LAST post on the reddit page or maybe I cannot tell since the alert box cannot show the enormous JSON response?</p>
  
  <p>I figured this was the case and tried:</p>
  
  <pre><code>var xmlHttp = new XMLHttpRequest();
  xmlHttp.onreadystatechange = function () {
      if (xmlHttp.readyState == 4 &amp;&amp; xmlHttp.status == 200)
          parseResponse(xmlHttp.responseText);
  }
  xmlHttp.open("GET", url, true); // true for asynchronous 
  xmlHttp.send(null);
  
  
  function parseResponse(responseText) {
  var x = (JSON.parse(responseText));
  alert(x.count);
  
  }
  </code></pre>
  
  <p>but got a undefined in the alert box. Any ideas? </p>
  
  <p>Goal is to get the 25 front page of reddit JSON responses information (identifiers)</p>