Home arrow ColdFusion arrow Page 3 - CFAjax: What it is and How to Use it

CFAjax: What it is and How to Use it

This is for ColdFusion aficionados who want to use Ajax. Ajax is implemented in such a way that ColdFusion method calls on the server gets executed using JavaScript a la Ajax. This tutorial shows you where to get the code and how to implement it on your local server.

Author Info:
By: Jayaram Krishnaswamy
Rating: 4 stars4 stars4 stars4 stars4 stars / 59
February 14, 2006
  1. · CFAjax: What it is and How to Use it
  2. · Implemented ColdFusion Function
  3. · CFAjax implementation of a ColdFusion function
  4. · Code Analysis: The External js files
  5. · MyCFAjax.htm file

print this article

CFAjax: What it is and How to Use it - CFAjax implementation of a ColdFusion function
(Page 3 of 5 )

In this case, the same function will be used as in the previous case. The values for x and y will be pulled from two textboxes in the client file MyCFajax.htm sent to the server.  The JavaScript on this file looks up external .js files on the server in the core folder. Some of the example files in the example folder may not work right away for you because of the way the external .js files are referenced in the examples. In writing MyCFajax.htm the relative references are substituted by absolute references and therefore should work without a problem.

This is the complete MyCFAjax.htm file. Some of the alert statements have been added to monitor the JavaScript functions.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//
EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1"> <title>CFAJAX_1: A simple Function</title> <script type='text/javascript' src='http://
localhost/ajax/core/engine.js'></script> <script type='text/javascript' src='http://
localhost/ajax/core/util.js'></script> <script type='text/javascript' src='http://
localhost/ajax/core/settings.js'></script> <script language="javascript"> _cfscriptLocation = "http://localhost/ajax/examples/
functions.cfm"; </script> <script> function loadInfo() { var x= DWRUtil.getValue("x"); //alert(x); var y= DWRUtil.getValue("y"); //alert(y); //alert("loadinfo() ran"); DWREngine._execute (_cfscriptLocation, null, "RightAngleTriangle",
x, y, getResult); } function getResult(result) { //alert ("getResult running"); document.getElementById("info").innerHTML = result; } function init() { //alert ("init() function ran"); DWRUtil.useLoadingMessage(); DWREngine._errorHandler = errorHandler; loadInfo(); } </script> <body onLoad="init();"> <span name="info" id="info" style="background:#eeffdd; padding-left:
4px; padding-right:4px;">xxx</span> <input id="x" name="x" value=3> <input id="y" name="y" value=4> </body> </html>

blog comments powered by Disqus

- Adobe ColdFusion Just Got More RAD
- How to Access a SQL Anywhere Database with C...
- CFXML: Probing XMLDOM in ColdFusion
- Creating a Web Service with ColdFusion: the ...
- CFAjax: What it is and How to Use it
- Querying SQL 2000 Server from ColdFusion
- Introduction to ColdFusion Markup Language, ...
- Introduction to ColdFusion Markup Language
- Databases and Dreamweaver MX 2004, concluded
- Databases and Dreamweaver MX 2004
- Welcome to Coldfusion MX 6.1, concluded
- Welcome to Coldfusion MX 6.1
- What You Must Know About ColdFusion Flow-Con...
- What You Must Know About Operators in ColdFu...
- Everything You Must Know About ColdFusion Va...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials