title: Coldfusion: Displaying Updated total count from Database cfajaxproxy
body: <p>I'm not good in javascript, Ajax &amp; Jquery but I still have to finish one task. I'm trying to show an updated record count at runtime. This will be live report for management, the number should change without refreshing the page. I tried to write a script but still failed. Found one jquery script online, I modified it but I'm not getting the desired result, I'm  getting an error. I didn't find a helpful example from a google search. If you have have any supporting or helpful example, please share.</p>
  
  <p>This is what I did so far:</p>
  
  <p>CFC: counter function just running one loop but actually here ill fetch data from database.</p>
  
  <pre><code>&lt;cfcomponent&gt;
  &lt;cffunction name="counter" returntype="any" access="remote" &gt;
      &lt;cfset var o= 1&gt;
      &lt;cfloop index="b" from="1" to="1000"&gt;
          &lt;cfset o = b&gt;
          &lt;cfset sleep = 1000&gt;
       &lt;/cfloop&gt;
  &lt;cfreturn o&gt;
  &lt;/cffunction&gt;
  </code></pre>
  
  <p></p>
  
  <p>CFM File:</p>
  
  <pre><code>&lt;cfajaxproxy cfc="async" jsclassname="asyncjs" /&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;body&gt;
      &lt;div id="saa"&gt;&lt;span class="count"&gt;200&lt;/span&gt;&lt;/div&gt;
  &lt;div style="clear:both"&gt;&lt;/div&gt;
  &lt;div id="talkbubble"&gt;&lt;span class="count"&gt;1421&lt;/span&gt;&lt;/div&gt;
  &lt;br /&gt;
      &lt;script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'&gt;&lt;/script&gt;
  
       &lt;script type="text/javascript"&gt;
          var objCfc =  new asyncjs();
              objCfc.setAsyncMode();
  
              alert(objCfc.counter());
              $('.count').each(function () {
                  var i =300;
                  $(this).prop('Counter',0).animate({
                      Counter: $(this).text()
                  }, {
                      duration: 4000,
                      easing: 'swing',
                      step: function () {
                          //$(this).text(Math.ceil(now)
  
                          $(this).text(i);
                      }
                  });
              });
          &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Please advise...</p>