I have a customer that utilizes a third party web service for their end users to gather information. In this case, it was to get information on vehicles based upon their VIN number. I built a ColdFusion Component (CFC) to hit the web service, parse through the XML and pull back the appropriate data.
I then built a CFFORM to house the returned data in cfinput text fields. The goal was to save end users time by filling out the form for them. Within the form, I had a field where the end user could input the VIN. I had this working well with binding and all so that when the VIN was inserted all the fields were filled in...cool.
But there was an issue. The end users were used to clicking a button to have the fields fill in and wanted to take that action. So I had to come up with a way to have the calls to the CFC take place upon clicking said button. Problem was that I was not quite sure how to do this. I have done stuff like that with straight CF and straight JS, but never the combo.
So utilizing cfajaxproxy and JSON, I was able to get this to work. Allow me to show this.. (kudos to learncf that pointed me in the right direction).
First I set the AJAX stuff up by using the cfajaxproxy tag. This makes the connection to the cfc utilizing JSON.
<cfajaxproxy cfc="proxy" jsclassname="proxy" />
Then I wrote the JS script that hit the appropriate method to pull the info from the cfc.
function getYearvin(source) {var instance = new proxy();instance.setCallbackHandler(getYearvinSuccess);instance.getYearvin(source);}function getYearvinSuccess(result) {document.getElementById('year').value = result;}~Clay
Rate this
Comments
Tag Cloud
- 1 item is tagged with tagged with AJAX
- 1 item is tagged with tagged with Business Marketing
- 1 item is tagged with tagged with christian
- 1 item is tagged with tagged with church
- 1 item is tagged with tagged with ColdFusion
- 1 item is tagged with tagged with JavaScript
- 1 item is tagged with tagged with JSON
- 1 item is tagged with tagged with Life
- 1 item is tagged with tagged with Marketing
- 1 item is tagged with tagged with ministry
- 1 item is tagged with tagged with nonprofit
- 1 item is tagged with tagged with Site Updates
- 1 item is tagged with tagged with small business
- 2 items are tagged with tagged with Web Design
- 3 items are tagged with tagged with Web Development
- 1 item is tagged with tagged with Web Site
- 1 item is tagged with tagged with website design