<script type='text/javascript'> _ajaxConfig = { '_cfscriptLocation':'echoTest.cfc', '_jsscriptFolder':'../js', 'debug':true}; </script> <script type='text/javascript' src='../js/ajax.js'></script> <script type="text/javascript"> function doEcho() { // get value from input var str = $('echoInput').value; // reset input value $('echoInput').value=''; // focus input again $('echoInput').focus(); // send data to CF DWREngine._execute(_ajaxConfig._cfscriptLocation, null, 'echo', str, doEchoResult); } // call back function function doEchoResult (r) { // appends response to div $('echoScreen').innerHTML = $('echoScreen').innerHTML + '<BR>' + r; } </script> <fieldset> <legend>ajaxCFC simple echo example</legend> <form onsubmit="doEcho();return false;"> <input type="Text" id="echoInput"><input type="submit" value="enter"> </form> </fieldset>
<cfcomponent extends="ajax"> <cffunction name="echo" output="no" access="private"> <cfargument name="str" required="Yes" type="string"> <cfreturn arguments.str /> </cffunction> </cfcomponent>