CFAjax: What it is and How to Use it (Page 1 of 5 )
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.
As you would expect, I will also describe an (extremely simple) to show how the code works. After this the reader may experiment with other samples provided by the CFAjax site. Some of the examples may not work immediately unless the virtual directory for testing is set up in a certain way.
From where do you download?First thing first, you may download CFAjax from here. In writing this tutorial, the Zip file, cfajax.1.3.zip was down loaded to the local machine. CFAjax is the name of a new folder located on the desktop at: C:\Documents and Settings\computer user\Desktop\CFAJAX\ into which the contents of the zip file were unzipped.
How do you set it up?In this step you will set up a virtual directory to park your downloaded files on your local server. It is assumed that your web site can handle ColdFusion files. If not, I suggest you read this article on ASP Free.
Open your IIS in the MMC (Microsoft Management Console). Expand the Web Sites folder to reveal the Default Web Site. Right click on Default Web Site and choose New -> Virtual Directory... as shown.

The Virtual Directory Creation wizard opens up. Click on Next in the Welcome screen. For the Virtual Directory Alias enter ajax as shown and click Next>. It is important you do not change, or use your own. Once you get familiar with this process you can do what you like.

This opens up the window where you need to indicate the location from which content is coming. For the Web Site Content Directory click on the Browse... button and locate the CFAjax directory where you unzipped the downloaded zip file. This is chosen by expanding nodes in the Browse for Folder tree view window.

You should see the following in the directory information textbox in For the Web Site Content Directory: C:\Documents and Settings\computer user\Desktop\CFAJAX.
Click Next. In the screen that follows accept the default permissions as shown in permissions. You can change them later if necessary.

After accepting the default permissions, click on Next. This completes your virtual directory. Now your ajax virtual directory should appear as shown in the next picture.

Now you are ready to use and develop programs for CFAJAX. The CFAjax installation has the folders, app, core, examples, and utility. It also has its default.htm. The directory hodentek has been added to keep files developed separate from the original files.
CFAjax folder contentsNow you are ready to use and develop programs for CFAJAX. The CFAjax installation has the following folders: app, core, examples, and utility. It also has its default.htm. Most of the required items are in the folders core and utility. The app and examples folders contain code developed using functionalities in core and utility. The core folder contains the JavaScript files, engine.js and util.js. The XMLHTTP object is contained in a DWRengine function in CFAjax. The util.js helps in sending parameters (arguments) and presenting return values via the DOM. The DWRengine's execute () method is the one that sends the data to the server via XMLHttp ().
Next: Implemented ColdFusion Function >>
More ColdFusion Articles
More By Jayaram Krishnaswamy