This post is more than 2 years old.
James Brown (yes, him) asks:
Yep, and it's so easy, it's rather trivial. As long as you can make a HTTP request with Ajax, then you can run any code you would imagine.
I've been blogging about jQuery pretty extensively lately so let's do this one just using what ships in ColdFusion 8. First, I'll create a simple form:
<form> Set Name: <input type="text" name="name" /> <input type="button" value="Set" id="btn" /> </form>
Next I'll use the cfajaxproxy to bind to the name form field.
<cfparam name="url.name" default=""> <cfset client.name = url.name>
And that's it. You may want to change when the Ajax call is made. By default it is fired with the onBlur event. So if you click the set button, or anything else on the page, the Ajax call is made. You could modify things a bit and tell it to fire just on the button click:
This bind expression means: Pass name, but don't monitor it (none), and monitor the btn button's click event. Why is there a & between the two binds? I needed a valid URL for the request and the bind has to actually be in the URL itself. Not quite as obvious and simple as the first example, but it gives you a bit more control by running just when the button is clicked.