As you know, there are a lot of Ajax UI in CF8. Among them, I love to use Coldfusion.Ajax.submitForm function. When I was on cfmx7, I need to use classic ajax coding or jQuery coding for submitting form. Once I'm on cf8, adobe support me to develop ajax form submit function in just 5 mins. That's why I love CFML. Ok, let's go how to use : If you want to develop with Ajax function, you need to put cfajaximport tag at the top of your page.

index.cfm

view plain print about
1<html>
2 <head>
3 <cfajaximport>
4 <invalidTag type="text/javascript">
5            function submitForm() {
6            ColdFusion.Ajax.submitForm('myform', 'formAction.cfm', callback, errorHandler);
7            }
8            function callback(text) {
9            document.getElementById("divShowMsg").innerHTML = text;
10            }
11            function errorHandler(code, msg) { alert("Error " + code + ": " + msg); }
12        </script>
13 </head>
14 <body>
15 <div id="divShowMsg"></div>
16 <cfform name="myform">
17 Enter your email:
18 <br>
19 <cfinput name="txtEmail" />
20 <cfinput name="btnSubmit" value="Submit" type="button" onclick="submitForm()" />
21 </cfform>
22 </body>
23</html>

for callback function It's built-in function of ajaxformsubmit and which check whether your data has been successfully reach or not. If reach, you can show any message within this scope. It always return string value. formAction.cfm

view plain print about
1<cfif form.txtEmail NEQ "">
2 <cfoutput>
3 Your email(#form.txtEmail#) has been successfully subscribed.
4 </cfoutput>
5<cfelse>
6 Please enter email address.
7</cfif>