title: Disqus API Comment Count Tutorial - Where do I put the javascript code?
body: <p>I am trying to troubleshoot what I have done wrong here, coz it's not working.</p>
  
  <p>I've been following the Disqus API Tutorial here: <a href="http://help.disqus.com/customer/portal/articles/1131783-tutorial-get-comment-counts-with-the-api" rel="nofollow">http://help.disqus.com/customer/portal/articles/1131783-tutorial-get-comment-counts-with-the-api</a>. </p>
  
  <p>I've followed everything, but nothing happens when I click on the button. There are so many variables that can go wrong here, but I'm hoping that it's just my HTML.</p>
  
  <p>Thanks,
  Sar</p>
  
  <p>Here's my code:</p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
      &lt;html&gt;
          &lt;head&gt;
              &lt;title&gt;Disqus Comment Counts Example&lt;/title&gt;
  
      &lt;script src="http://code.jquery.com/jquery-1.8.3.min.js"&gt;&lt;/script&gt;
  
  
      &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
        var disqusPublicKey = "DELETED FOR SECURITY -DISQUSPUBLICKEY";
        var disqusShortname = "DELETED FOR SECURITY-MYDISQUSSHORTNAME"; // Replace with your own shortname
  
        var urlArray = [];
  
      $('.count-comments').each(function () {
        var url = $(this).attr('data-disqus-url');
        urlArray.push('link:' + url);
  
      });
  
  
      $('#get-counts-button').click(function () {
        $.ajax({
          type: 'GET',
          url: "https://disqus.com/api/3.0/threads/set.jsonp",
          data: { api_key: disqusPublicKey, forum : disqusShortname, thread : urlArray },
          cache: false,
          dataType: 'jsonp',
          success: function (result) {
  
            for (var i in result.response) {
  
              var countText = " comments";
              var count = result.response[i].posts;
  
              if (count == 1)
                countText = " comment";
  
              $('div[data-disqus-url="' + result.response[i].link + '"]').html('&lt;h4&gt;' + count + countText + '&lt;/h4&gt;');
  
            }
          }
        });
      });
  
      &lt;/script&gt;
  
       &lt;/head&gt;
          &lt;body&gt;
              &lt;h1&gt;Comment Counts Example&lt;/h1&gt;
  
  
  
   &lt;div&gt;
              &lt;a href=” folder/page-1.html”&gt;
                  &lt;h2&gt;Test Post One&lt;/h2&gt;
                  &lt;div class=”count-comments” data-disqus-url=”http://www.mysite.com/folder/page-1.html”&gt;&lt;/div&gt;
              &lt;/a&gt;
          &lt;/div&gt;
    &lt;div&gt;
              &lt;a href=”folder/page-2”&gt;
                  &lt;h2&gt;Test Post Two&lt;/h2&gt;
                  &lt;div class=”count-comments” data-disqus-url=”http://www.mysite.com/folder/page-2.html”&gt;&lt;/div&gt;
              &lt;/a&gt;
          &lt;/div&gt;
  
  
              &lt;button type="button" id="get-counts-button"&gt;Get Comment Counts&lt;/button&gt;
       &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>