title: ColdFusion and AJAX - Updating Database
body: <p>I'm wanting to have a system set up where users can go to a page where there's a list of items that they can rate (say, 1 through 5) from a drop-down. This list is going to get quite long thus it would be much more convenient if they could go through and rank each item without ever having to hit "Save."</p>
  
  <p>I'm <strong>very</strong> much a novice when it comes to AJAX but I figure this can't be <em>that</em> difficult. I found <a href="https://stackoverflow.com/a/15209183/4103070">an answer in a different discussion</a> that I think is quite relevant but it doesn't provide enough information for me to know exactly what to do with it.</p>
  
  <p>In short, how do I use AJAX, in congruence with jQuery and ColdFusion, to update the database without the need for a save/submit button?</p>
  
  <p><strong>CLARIFICATION:</strong> I should have clarified that the user can rate the items - not rank. Meaning that there's no #1, #2, #3, etc. Instead, each item can be rated on a scale from 1-5.</p>
  
  <p>Currently I'm basing everything off of ".change()" when the user makes a selection in the drop-down. At which point I have two jQuery variables that are set to the "ID" of the item changed as well as its new "rating." I just need to find a way to use these two variables to update the table in the database.</p>
  
  <p><h1>Update</h1>On the main page, I now have a simple jQuery AJAX post call: <code>$.post('update.cfc', {ID: inputID, rating: selRat})</code> that is triggered <code>.onChange()</code>. "inputID" is the ID of the entry that I want to update in the database and "selRat" is the selected rating in the drop-down.</p>
  
  <pre><code>&lt;cfcomponent output="false"&gt;
  &lt;cffunction name="updateRating" access="remote" output="false"&gt;
  
      &lt;cfupdate datasource="#session.db#" name="update"&gt;
          UPDATE ajaxTest
          SET rating = #FORM.rating#
          WHERE ID = #FORM.ID#
      &lt;/cfupdate&gt;
  
  &lt;/cffunction&gt;
  &lt;/cfcomponent&gt;
  </code></pre>
  
  <p>I'm currently getting a <code>500 (Internal Server Error)</code>.</p>
  
  <p>Thoughts/suggestions?</p>