title: How to call cffunction on the cfm page from javascript?
body: <p>I was wondering if I can call <code>cffunction</code> on my cfm page? I have <code>onClick</code> button that should make a call to the <code>cffunction</code> that is on the same page. Also I have tried to put <code>cfcomponent</code> around my function but I was getting this error:  </p>
  
  <pre><code>Invalid CFML construct found on line 94 at column 1.
  ColdFusion was looking at the following text:
  
  &amp;lt;
  The CFML compiler was processing:
  &amp;lt; marks the beginning of a ColdFusion tag.Did you mean LT or LTE?
  </code></pre>
  
  <p>So far I have this:</p>
  
  <pre><code>&lt;cffunction name="getRecords" access="remote"&gt;
      &lt;script&gt;
          alert('test');
      &lt;/script&gt;
  &lt;/cffunction&gt;
  </code></pre>
  
  <p>here is my JS Function:</p>
  
  <pre><code>function getRecs(){
      try{
          location.href = 'myCFMpage.cfm?method=getRecords';
      }catch(err){
          alert('Error')
      }   
  }
  </code></pre>
  
  <p>I'm not sure if this even possible, my current code did not trigger alert in <code>cffunction</code>. Reason why I'm trying to do this because I have a <code>cfquery</code> on this page and I want to grab the data from that query when user click on the button and then to do some manipulation. If anyone can tell me if this is possible or is there any better way to approach this problem please let me know.   </p>